Part Number Hot Search : 
HT6740 HR311A C5315 101MC FR305PT LTC35 STEVA 5V820A
Product Description
Full Text Search
 

To Download HD6433039VF Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  to our customers, old company name in catalogs and other documents on april 1 st , 2010, nec electronics corporation merged with renesas technology corporation, and renesas electronics corporation took over all the business of both companies. therefore, although the old company name remains in this document, it is a valid renesas electronics document. we appreciate your understanding. renesas electronics website: http://www.renesas.com april 1 st , 2010 renesas electronics corporation issued by: renesas electronics corporation ( http://www.renesas.com ) send any inquiries to http://www.renesas.com/inquiry .
notice 1. all information included in this document is current as of the date this document is issued. such information, however, is subject to change without any prior notice. before purchasing or using any renesas electronics products listed herein, please confirm the latest product information with a renesas electronics sales office. also, please pay regular and careful attention to additional and different information to be disclosed by renesas electronics such as that disclosed through our website. 2. renesas electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property ri ghts of third parties by or arising from the use of renesas electronics products or technical information described in this document . no license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property right s of renesas electronics or others. 3. you should not alter, modify, copy, or otherwise misappropriate any renesas electronics product, whether in whole or in part . 4. descriptions of circuits, software and other related information in this document are provided only to illustrate the operat ion of semiconductor products and application examples. you are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment. renesas electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits, software, or information. 5. when exporting the products or technology described in this document, you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations. you should not use renesas electronics products or the technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the development of weapons of mass destruction. renesas electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. 6. renesas electronics has used reasonable care in preparing the information included in this document, but renesas electronics does not warrant that such information is error free. renesas electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein. 7. renesas electronics products are classified according to the following three quality grades: ?standard?, ?high quality?, an d ?specific?. the recommended applications for each renesas electronics product depends on the product?s quality grade, as indicated below. you must check the quality grade of each renesas electronics product before using it in a particular application. you may not use any renesas electronics product for any application categorized as ?specific? without the prior written consent of renesas electronics. further, you may not use any renesas electronics product for any application for which it is not intended without the prior written consent of renesas electronics. renesas electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any renesas electronics product for a n application categorized as ?specific? or for which the product is not intended where you have failed to obtain the prior writte n consent of renesas electronics. the quality grade of each renesas electronics product is ?standard? unless otherwise expressly specified in a renesas electronics data sheets or data books, etc. ?standard?: computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots. ?high quality?: transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; an ti- crime systems; safety equipment; and medical equipment not specifically designed for life support. ?specific?: aircraft; aerospace equipment; submersible repeaters; nuclear reactor control systems; medical equipment or systems for life support (e.g. artificial life support devices or systems), surgical implantations, or healthcare intervention (e.g. excision, etc.), and any other applications or purposes that pose a direct threat to human life. 8. you should use the renesas electronics products described in this document within the range specified by renesas electronics , especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. renesas electronics shall have no liability for malfunctions o r damages arising out of the use of renesas electronics products beyond such specified ranges. 9. although renesas electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. fur ther, renesas electronics products are not subject to radiation resistance design. please be sure to implement safety measures to guard them against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a renesas electronics product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. because the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 10. please contact a renesas electronics sales office for details as to environmental matters such as the environmental compatibility of each renesas electronics product. please use renesas electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the eu rohs directive. renesas electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations. 11. this document may not be reproduced or duplicated, in any form, in whole or in part, without prior written consent of renes as electronics. 12. please contact a renesas electronics sales office if you have any questions regarding the information contained in this document or renesas electronics products, or if you have any other inquiries. (note 1) ?renesas electronics? as used in this document means renesas electronics corporation and also includes its majority- owned subsidiaries. (note 2) ?renesas electronics product(s)? means any product developed or manufactured by or for renesas electronics.
h8/3039 group, h8/3039f-ztat? hardware manual 16 users manual rev.3.00 2007.03 renesas 16-bit single-chip microcomputer h8 family / h8/300h series h8/3039 hd64f3039f hd64f3039te hd64f3039vf hd64f3039vte hd6433039f hd6433039te HD6433039VF hd6433039vte h8/3038 hd6433038f hd6433038te hd6433038vf hd6433038vte h8/3037 hd6433037f hd6433037te hd6433037vf hd6433037vte h8/3036 hd6433036f hd6433036te hd6433036vf hd6433036vte
rev.3.00 mar. 26, 2007 page ii of xxii rej09b0353-0300 1. this document is provided for reference purposes only so that renesas customers may select the appropriate renesas products for their use. renesas neither makes warranties or representations with respect to the accuracy or completeness of the information contained in this document nor grants any license to any intellectual property rights or any other rights of renesas or any third party with respect to the information in this document. 2. renesas shall have no liability for damages or infringement of any intellectual property or other rights arising out of the use of any information in this document, including, but not limited to, product data, diagrams, charts, programs, algorithms, and application circuit examples. 3. you should not use the products or the technology described in this document for the purpose of military applications such as the development of weapons of mass destruction or for the purpose of any other military use. when exporting the products or technology described herein, you should follow the applicable export control laws and regulations, and procedures required by such laws and regulations. 4. all information included in this document such as product data, diagrams, charts, programs, algorithms, and application circuit examples, is current as of the date this document is issued. such information, however, is subject to change without any prior notice. before purchasing or using any renesas products listed in this document, please confirm the latest product information with a renesas sales office. also, please pay regular and careful attention to additional and different information to be disclosed by renesas such as that disclosed through our website. (http://www.renesas.com ) 5. renesas has used reasonable care in compiling the information included in this document, but renesas assumes no liability whatsoever for any damages incurred as a result of errors or omissions in the information included in this document. 6. when using or otherwise relying on the information in this document, you should evaluate the information in light of the total system before deciding about the applicability of such information to the intended application. renesas makes no representations, warranties or guaranties regarding the suitability of its products for any particular application and specifically disclaims any liability arising out of the application and use of the information in this document or renesas products. 7. with the exception of products specified by renesas as suitable for automobile applications, renesas products are not designed, manufactured or tested for applications or otherwise in systems the failure or malfunction of which may cause a direct threat to human life or create a risk of human injury or which require especially high quality and reliability such as safety systems, or equipment or systems for transportation and traffic, healthcare, combustion control, aerospace and aeronautics, nuclear power, or undersea communication transmission. if you are considering the use of our products for such purposes, please contact a renesas sales office beforehand. renesas shall have no liability for damages arising out of the uses set forth above. 8. notwithstanding the preceding paragraph, you should not use renesas products for the purposes listed below: (1) artificial life support devices or systems (2) surgical implantations (3) healthcare intervention (e.g., excision, administration of medication, etc.) (4) any other purposes that pose a direct threat to human life renesas shall have no liability for damages arising out of the uses set forth in the above and purchasers who elect to use renesas products in any of the foregoing applications shall indemnify and hold harmless renesas technology corp., its affiliated companies and their officers, directors, and employees against any and all damages arising out of such applications. 9. you should use the products described herein within the range specified by renesas, especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. renesas shall have no liability for malfunctions or damages arising out of the use of renesas products beyond such specified ranges. 10. although renesas endeavors to improve the quality and reliability of its products, ic products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. please be sure to implement safety measures to guard against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a renesas product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other applicable measures. among others, since the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 11. in case renesas products listed in this document are detached from the products to which the renesas products are attached or affixed, the risk of accident such as swallowing by infants and small children is very high. you should implement safety measures so that renesas products may not be easily detached from your products. renesas shall have no liability for damages arising out of such detachment. 12. this document may not be reproduced or duplicated, in any form, in whole or in part, without prior written approval from renesas. 13. please contact a renesas sales office if you have any questions regarding the information contained in this document, renesas semiconductor products, or if you have any other inquiries. notes regarding these materials
rev.3.00 mar. 26, 2007 page iii of xxii rej09b0353-0300 general precautions in the handling of mpu/mcu products the following usage notes are applicable to all mpu/mcu products from renesas. for detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. if the descriptions under general precautions in the handling of mpu/mcu products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1. handling of unused pins handle unused pins in accord with the directions given under handling of unused pins in the manual. ? the input pins of cmos products are generally in the high-impedance state. in operation with an unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of lsi, an associated shoot-through current flows internally, and malfunctions may occur due to the false recognition of the pin state as an input signal. unused pins should be handled as described under handling of unused pins in the manual. 2. processing at power-on the state of the product is undefined at the moment when power is supplied. ? the states of internal circuits in the lsi are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied. in a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. in a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified. 3. prohibition of access to reserved addresses access to reserved addresses is prohibited. ? the reserved addresses are provided for the possible future expansion of functions. do not access these addresses; the correct operation of lsi is not guaranteed if they are accessed. 4. clock signals after applying a reset, only release the reset line after the operating clock signal has become stable. when switching the clock signal during program execution, wait until the target clock signal has stabilized. ? when the clock signal is generated with an external resonator (or from an external oscillator) during a reset, ensure that the reset line is only released after full stabilization of the clock signal. moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable. 5. differences between products before changing from one product to another, i.e. to one with a different type number, confirm that the change will not lead to problems. ? the characteristics of mpu/mcu in the same group but having different type numbers may differ because of the differences in internal memory capacity and layout pattern. when changing to products of different type numbers, implement a system-evaluation test for each of the products.
rev.3.00 mar. 26, 2007 page iv of xxii rej09b0353-0300
rev.3.00 mar. 26, 2007 page v of xxii rej09b0353-0300 preface the h8/3039 group comprises high-performance single-chip microcomputers (mcus) that integrate system supporting functions together with an h8/300h cpu core. the h8/300h cpu has a 32-bit internal architecture with sixteen 16-bit general registers, and a concise, optimized instruction set designed for speed. it can address a 16-mbyte linear address space. the on-chip system supporting functions include rom, ram, a 16-bit integrated timer unit (itu), a programmable timing pattern controller (tpc), a watchdog timer (wdt), a serial communication interface (sci), an a/d converter, i/o ports, and other facilities. of the two sci channels, one has been expanded to support the iso/iec 7816-3 smart card interface. functions have also been added to reduce power consumption in battery-powered applications: individual modules can be placed in standby, and the frequency of the system clock supplied to the chip can be divided down under software control. the five mcu operating modes offer a choice of expanded mode, single-chip mode, and address space size, enabling the h8/3039 group to adapt quickly and flexibly to a variety of conditions. in addition to its mask-rom versions, the h8/3039 group has an f-ztat? version with user programmable on-chip flash memory that can be programmed on-board. these versions enable users to respond quickly and flexibly to changing application specifications. this manual describes the h8/3039 group hardware. for details of the instruction set, refer to the h8/300h series software manual. note: f-ztat is a trademark of renesas technology corp.
rev.3.00 mar. 26, 2007 page vi of xxii rej09b0353-0300
rev.3.00 mar. 26, 2007 page vii of xxii rej09b0353-0300 main revisions for this edition item page revision (see manual for details) all ? ? notification of change in company name amended (before) hitachi, ltd. (after) renesas technology corp. ? product naming convention amended (before) h8/3039 series (after) h8/3039 group 2.3 address space figure 2.2 memory map 20 figure amended 1. normal mode (64-kbyte mode) h'0000 h'ffff 5.2.2 interrupt priority registers a and b (ipra, iprb) interrupt priority register b (iprb) 91 description amended bit initial value read/write 7 iprb7 0 r/w 6 iprb6 0 r/w 5 ? 0 r/w 4 ? 0 r/w 3 iprb3 0 r/w 0 ? 0 r/w 2 iprb2 0 r/w 1 iprb1 0 r/w 5.2.3 irq status register (isr) 93 description amended bits 5, 4, 1 and 0 ? irq 5 , irq 4 , irq 1 and irq 0 flags (irq5f, irq4f, irq1f, and irq0f): these bits indicate the status of irq 5 , irq 4 , irq 1 , and irq 0 interrupt requests. 5.2.4 irq enable register (ier) 94 description amended bit initial value read/write 7 ? 0 r/w 6 ? 0 r/w reserved bits bits 5, 4, 1, and 0 ? irq 5 , irq 4 , irq 1 , and irq 0 enable (irq5e, irq4e, irq1e, irq0e): these bits enable or disable irq5 , irq4 , irq1 , irq0 interrupts.
rev.3.00 mar. 26, 2007 page viii of xxii rej09b0353-0300 item page revision (see manual for details) 5.3.3 interrupt vector table table 5.3 interrupt sources, vector addresses, and priority 98 table amended wovi ( interval timer) 5.5.4 usage notes figure 5.9 irqnf flag when interrupt exception handling is not executed 109 figure amended 1 read 0 written 1 read 0 written generation condition (2) (inadvertent clearing) 6.4.2 precautions on setting astcr and abwcr * 131 description amended modes 5 and 7 astcr0 = 0 abwcr = h'fc 11.2.8 bit rate register (brr) 349 description added the baud rate generator is controlled separately for the individual channels, so different values may be set for each. table 11.3 examples of bit rates and brr settings in asynchronous mode 351 table amended (mhz) 12 bit rate (bits/s) n n error (%) 300 277 0.16 11.3.4 synchronous operation clock 376 description amended an internal clock generated by the on-chip baud rate generator or an external clock input from the sck pin can be selected by clearing or setting the cke1 and cke0 bits in scr and the c/ a bit in smr. see table 11.9.
rev.3.00 mar. 26, 2007 page ix of xxii rej09b0353-0300 item page revision (see manual for details) 16.2.1 connecting a crystal resonator table 16.2 crystal resonator parameters 500 preliminary deleted 18.1.3 ac characteristics table 18.5 control signal timing 532 table amended condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions res setup time t ress 200 ? 200 ? 200 ? ns figure 18.10 res pulse width t resw 10 ? 10 ? 10 ? tcyc mode programming setup time (md 0 , md 1 , md 2 ) t 200 ? 200 ? 200 ? ns mds 18.1.4 a/d conversion characteristics 535 newly added 18.2.2 dc characteristics table 18.10 permissible output currents 541 table amended item permissible output low current (total) total of 27 pins including ports 1, 2, 5 and b a.1 instruction list 8. block transfer instructions 576 table amended mnemonic operation eepmov. w ? if r4 ? operand size a.3 number of states required for execution table a.4 number of cycles per instruction 584 table amended instruction mnemonic word data access m internal operation n bsr bsr d:16 normal 2 advanced 2
rev.3.00 mar. 26, 2007 page x of xxii rej09b0353-0300 all trademarks and registered trademarks are the property of their respective owners.
rev.3.00 mar. 26, 2007 page xi of xxii rej09b0353-0300 contents section 1 overview ............................................................................................................. 1 1.1 overview.................................................................................................................... ....... 1 1.2 block diagram ............................................................................................................... ... 6 1.3 pin description............................................................................................................. ..... 7 1.3.1 pin arrangement .................................................................................................. 7 1.3.2 pin functions ....................................................................................................... 8 1.4 pin functions ............................................................................................................... ..... 12 section 2 cpu ...................................................................................................................... 17 2.1 overview.................................................................................................................... ....... 17 2.1.1 features................................................................................................................ 17 2.1.2 differences from h8/300 cpu............................................................................. 18 2.2 cpu operating modes ...................................................................................................... 19 2.3 address space ............................................................................................................... .... 20 2.4 register configuration...................................................................................................... 21 2.4.1 overview.............................................................................................................. 21 2.4.2 general registers ................................................................................................. 22 2.4.3 control registers ................................................................................................. 23 2.4.4 initial cpu register values ................................................................................. 24 2.5 data formats ................................................................................................................ ..... 25 2.5.1 general register data formats ............................................................................ 25 2.5.2 memory data formats ......................................................................................... 27 2.6 instruction set ............................................................................................................. ...... 28 2.6.1 instruction set overview ..................................................................................... 28 2.6.2 instructions and addressing modes ..................................................................... 29 2.6.3 tables of instructions classified by function...................................................... 31 2.6.4 basic instruction formats .................................................................................... 40 2.6.5 notes on use of bit manipulation instructions.................................................... 41 2.7 addressing modes and effective address calculation ..................................................... 41 2.7.1 addressing modes ............................................................................................... 41 2.7.2 effective address calculation ............................................................................. 45 2.8 processing states........................................................................................................... .... 49 2.8.1 overview.............................................................................................................. 49 2.8.2 program execution state...................................................................................... 49 2.8.3 exception-handling state .................................................................................... 50 2.8.4 exception-handling sequences ........................................................................... 51 2.8.5 reset state............................................................................................................ 53
rev.3.00 mar. 26, 2007 page xii of xxii rej09b0353-0300 2.8.6 power-down state ............................................................................................... 53 2.9 basic operational timing ................................................................................................. 54 2.9.1 overview.............................................................................................................. 54 2.9.2 on-chip memory access timing........................................................................ 54 2.9.3 on-chip supporting module access timing ...................................................... 55 2.9.4 access to external address space ....................................................................... 56 section 3 mcu operating modes .................................................................................. 57 3.1 overview.................................................................................................................... ....... 57 3.1.1 operating mode selection ................................................................................... 57 3.1.2 register configuration......................................................................................... 58 3.2 mode control register (mdcr) ...................................................................................... 59 3.3 system control register (syscr) ................................................................................... 60 3.4 operating mode descriptions ........................................................................................... 62 3.4.1 mode 1 ................................................................................................................. 62 3.4.2 mode 3 ................................................................................................................. 62 3.4.3 mode 5 ................................................................................................................. 62 3.4.4 mode 6 ................................................................................................................. 62 3.4.5 mode 7 ................................................................................................................. 62 3.5 pin functions in each operating mode ............................................................................ 63 3.6 memory map in each operating mode ............................................................................ 63 3.7 restrictions on use of mode 6.......................................................................................... 72 section 4 exception handling ......................................................................................... 75 4.1 overview.................................................................................................................... ....... 75 4.1.1 exception handling types and priority............................................................... 75 4.1.2 exception handling operation ............................................................................ 75 4.1.3 exception vector table ....................................................................................... 76 4.2 reset....................................................................................................................... ........... 78 4.2.1 overview.............................................................................................................. 78 4.2.2 reset sequence .................................................................................................... 78 4.2.3 interrupts after reset............................................................................................ 80 4.3 interrupts.................................................................................................................. ......... 80 4.4 trap instruction............................................................................................................ ..... 81 4.5 stack status after exception handling.............................................................................. 81 4.6 notes on stack usage ....................................................................................................... 8 2 section 5 interrupt controller .......................................................................................... 83 5.1 overview.................................................................................................................... ....... 83 5.1.1 features................................................................................................................ 83 5.1.2 block diagram..................................................................................................... 84
rev.3.00 mar. 26, 2007 page xiii of xxii rej09b0353-0300 5.1.3 pin configuration................................................................................................. 85 5.1.4 register configuration......................................................................................... 85 5.2 register descriptions ....................................................................................................... .86 5.2.1 system control register (syscr) ...................................................................... 86 5.2.2 interrupt priority registers a and b (ipra, iprb)............................................. 88 5.2.3 irq status register (isr).................................................................................... 93 5.2.4 irq enable register (ier) .................................................................................. 94 5.2.5 irq sense control register (iscr) .................................................................... 95 5.3 interrupt sources ........................................................................................................... .... 96 5.3.1 external interrupts ............................................................................................... 96 5.3.2 internal interrupts................................................................................................. 97 5.3.3 interrupt vector table.......................................................................................... 97 5.4 interrupt operation......................................................................................................... ... 100 5.4.1 interrupt handling process................................................................................... 100 5.4.2 interrupt sequence ............................................................................................... 105 5.4.3 interrupt response time...................................................................................... 106 5.5 usage notes ................................................................................................................. ..... 107 5.5.1 contention between interrupt and interrupt-disabling instruction ...................... 107 5.5.2 instructions that inhibit interrupts........................................................................ 108 5.5.3 interrupts during eepmov instruction execution.............................................. 108 5.5.4 usage notes ......................................................................................................... 108 section 6 bus controller .................................................................................................... 111 6.1 overview.................................................................................................................... ....... 111 6.1.1 features................................................................................................................ 11 1 6.1.2 block diagram ..................................................................................................... 112 6.1.3 input/output pins ................................................................................................. 113 6.1.4 register configuration......................................................................................... 113 6.2 register descriptions ....................................................................................................... . 114 6.2.1 access state control register (astcr) ............................................................. 114 6.2.2 wait control register (wcr).............................................................................. 115 6.2.3 wait state controller enable register (wcer) .................................................. 116 6.2.4 address control register (adrcr).................................................................... 117 6.3 operation................................................................................................................... ........ 119 6.3.1 area division ....................................................................................................... 119 6.3.2 bus control signal timing .................................................................................. 121 6.3.3 wait modes.......................................................................................................... 123 6.3.4 interconnections with memory (example) .......................................................... 129 6.4 usage notes ................................................................................................................. ..... 131 6.4.1 register write timing ......................................................................................... 131 6.4.2 precautions on setting astcr and abwcr...................................................... 131
rev.3.00 mar. 26, 2007 page xiv of xxii rej09b0353-0300 section 7 i/o ports .............................................................................................................. 133 7.1 overview.................................................................................................................... ....... 133 7.2 port 1...................................................................................................................... ........... 137 7.2.1 overview.............................................................................................................. 137 7.2.2 register descriptions ........................................................................................... 138 7.2.3 pin functions in each mode ................................................................................ 140 7.3 port 2...................................................................................................................... ........... 142 7.3.1 overview.............................................................................................................. 142 7.3.2 register descriptions ........................................................................................... 143 7.3.3 pin functions in each mode ................................................................................ 145 7.3.4 input pull-up transistors..................................................................................... 147 7.4 port 3...................................................................................................................... ........... 148 7.4.1 overview.............................................................................................................. 148 7.4.2 register descriptions ........................................................................................... 148 7.4.3 pin functions in each mode ................................................................................ 150 7.5 port 5...................................................................................................................... ........... 152 7.5.1 overview.............................................................................................................. 152 7.5.2 register descriptions ........................................................................................... 153 7.5.3 pin functions in each mode ................................................................................ 155 7.5.4 input pull-up transistors..................................................................................... 156 7.6 port 6...................................................................................................................... ........... 157 7.6.1 overview.............................................................................................................. 157 7.6.2 register descriptions ........................................................................................... 158 7.6.3 pin functions in each mode ................................................................................ 160 7.7 port 7...................................................................................................................... ........... 163 7.7.1 overview.............................................................................................................. 163 7.7.2 register description............................................................................................. 163 7.8 port 8...................................................................................................................... ........... 164 7.8.1 overview.............................................................................................................. 164 7.8.2 register descriptions ........................................................................................... 165 7.8.3 pin functions ....................................................................................................... 167 7.9 port 9...................................................................................................................... ........... 168 7.9.1 overview.............................................................................................................. 168 7.9.2 register descriptions ........................................................................................... 168 7.9.3 pin functions ....................................................................................................... 170 7.10 port a..................................................................................................................... ........... 172 7.10.1 overview.............................................................................................................. 172 7.10.2 register descriptions ........................................................................................... 173 7.10.3 pin functions ....................................................................................................... 175 7.11 port b ..................................................................................................................... ........... 182 7.11.1 overview.............................................................................................................. 182
rev.3.00 mar. 26, 2007 page xv of xxii rej09b0353-0300 7.11.2 register descriptions ........................................................................................... 182 7.11.3 pin functions ....................................................................................................... 184 section 8 16-bit integrated timer unit (itu) ............................................................ 191 8.1 overview.................................................................................................................... ....... 191 8.1.1 features................................................................................................................ 19 1 8.1.2 block diagrams ................................................................................................... 194 8.1.3 input/output pins ................................................................................................. 199 8.1.4 register configuration......................................................................................... 201 8.2 register descriptions ....................................................................................................... . 204 8.2.1 timer start register (tstr)................................................................................ 204 8.2.2 timer synchro register (tsnc) ......................................................................... 206 8.2.3 timer mode register (tmdr) ............................................................................ 208 8.2.4 timer function control register (tfcr)............................................................ 211 8.2.5 timer output master enable register (toer) ................................................... 214 8.2.6 timer output control register (tocr) .............................................................. 216 8.2.7 timer counters (tcnt) ...................................................................................... 218 8.2.8 general registers (gra, grb)........................................................................... 219 8.2.9 buffer registers (bra, brb).............................................................................. 220 8.2.10 timer control registers (tcr) ........................................................................... 221 8.2.11 timer i/o control register (tior) ..................................................................... 223 8.2.12 timer status register (tsr)................................................................................ 225 8.2.13 timer interrupt enable register (tier) .............................................................. 227 8.3 cpu interface............................................................................................................... ..... 228 8.3.1 16-bit accessible registers ................................................................................. 228 8.3.2 8-bit accessible registers ................................................................................... 231 8.4 operation................................................................................................................... ........ 232 8.4.1 overview.............................................................................................................. 232 8.4.2 basic functions.................................................................................................... 234 8.4.3 synchronization ................................................................................................... 243 8.4.4 pwm mode.......................................................................................................... 245 8.4.5 reset-synchronized pwm mode......................................................................... 249 8.4.6 complementary pwm mode ............................................................................... 252 8.4.7 phase counting mode .......................................................................................... 261 8.4.8 buffering.............................................................................................................. 263 8.4.9 itu output timing .............................................................................................. 269 8.5 interrupts .................................................................................................................. ......... 272 8.5.1 setting of status flags.......................................................................................... 272 8.5.2 clearing of status flags ....................................................................................... 274 8.5.3 interrupt sources.................................................................................................. 275 8.6 usage notes ................................................................................................................. ..... 276
rev.3.00 mar. 26, 2007 page xvi of xxii rej09b0353-0300 section 9 programmable timing pattern controller ................................................. 291 9.1 overview.................................................................................................................... ....... 291 9.1.1 features................................................................................................................ 29 1 9.1.2 block diagram..................................................................................................... 292 9.1.3 tpc pins .............................................................................................................. 293 9.1.4 registers............................................................................................................... 29 4 9.2 register descriptions ....................................................................................................... . 295 9.2.1 port a data direction register (paddr) ........................................................... 295 9.2.2 port a data register (padr).............................................................................. 295 9.2.3 port b data direction register (pbddr) ........................................................... 296 9.2.4 port b data register (pbdr) .............................................................................. 296 9.2.5 next data register a (ndra) ............................................................................ 297 9.2.6 next data register b (ndrb)............................................................................. 299 9.2.7 next data enable register a (ndera).............................................................. 301 9.2.8 next data enable register b (nderb) .............................................................. 302 9.2.9 tpc output control register (tpcr) ................................................................. 303 9.2.10 tpc output mode register (tpmr) ................................................................... 306 9.3 operation ................................................................................................................... ....... 308 9.3.1 overview.............................................................................................................. 308 9.3.2 output timing ..................................................................................................... 309 9.3.3 normal tpc output............................................................................................. 310 9.3.4 non-overlapping tpc output............................................................................. 312 9.3.5 tpc output triggering by input capture ............................................................ 314 9.4 usage notes ................................................................................................................. ..... 315 9.4.1 operation of tpc output pins ............................................................................. 315 9.4.2 note on non-overlapping output........................................................................ 315 section 10 watchdog timer ............................................................................................. 317 10.1 overview................................................................................................................... ........ 317 10.1.1 features................................................................................................................ 3 17 10.1.2 block diagram..................................................................................................... 318 10.1.3 pin configuration................................................................................................. 318 10.1.4 register configuration......................................................................................... 319 10.2 register descriptions ...................................................................................................... .. 319 10.2.1 timer counter (tcnt)........................................................................................ 319 10.2.2 timer control/status register (tcsr)................................................................ 320 10.2.3 reset control/status register (rstcsr)............................................................ 322 10.2.4 notes on register access..................................................................................... 324 10.3 operation .................................................................................................................. ........ 326 10.3.1 watchdog timer operation ................................................................................. 326 10.3.2 interval timer operation ..................................................................................... 327
rev.3.00 mar. 26, 2007 page xvii of xxii rej09b0353-0300 10.3.3 timing of setting of overflow flag (ovf) ......................................................... 328 10.3.4 timing of setting of watchdog timer reset bit (wrst)................................... 329 10.4 interrupts ................................................................................................................. .......... 329 10.5 usage notes ................................................................................................................ ...... 330 section 11 serial communication interface ................................................................ 331 11.1 overview................................................................................................................... ........ 331 11.1.1 features................................................................................................................ 3 31 11.1.2 block diagram ..................................................................................................... 333 11.1.3 input/output pins ................................................................................................. 334 11.1.4 register configuration......................................................................................... 335 11.2 register descriptions ...................................................................................................... .. 336 11.2.1 receive shift register (rsr)............................................................................... 336 11.2.2 receive data register (rdr) .............................................................................. 336 11.2.3 transmit shift register (tsr) ............................................................................. 337 11.2.4 transmit data register (tdr)............................................................................. 337 11.2.5 serial mode register (smr)................................................................................ 338 11.2.6 serial control register (scr).............................................................................. 341 11.2.7 serial status register (ssr)................................................................................. 345 11.2.8 bit rate register (brr) ...................................................................................... 349 11.3 operation.................................................................................................................. ......... 358 11.3.1 overview.............................................................................................................. 358 11.3.2 operation in asynchronous mode ....................................................................... 360 11.3.3 multiprocessor communication........................................................................... 369 11.3.4 synchronous operation........................................................................................ 376 11.4 sci interrupts............................................................................................................. ....... 384 11.5 usage notes ................................................................................................................ ...... 385 section 12 smart card interface ..................................................................................... 391 12.1 overview................................................................................................................... ........ 391 12.1.1 features................................................................................................................ 3 91 12.1.2 block diagram ..................................................................................................... 392 12.1.3 pin configuration................................................................................................. 393 12.1.4 register configuration......................................................................................... 393 12.2 register descriptions ...................................................................................................... .. 394 12.2.1 smart card mode register (scmr) .................................................................... 394 12.2.2 serial status register (ssr)................................................................................. 396 12.3 operation.................................................................................................................. ......... 397 12.3.1 overview.............................................................................................................. 397 12.3.2 pin connections ................................................................................................... 398 12.3.3 data format ......................................................................................................... 399
rev.3.00 mar. 26, 2007 page xviii of xxii rej09b0353-0300 12.3.4 register settings .................................................................................................. 401 12.3.5 clock.................................................................................................................... 403 12.3.6 data transfer operations..................................................................................... 405 12.4 usage note................................................................................................................. ....... 411 section 13 a/d converter ................................................................................................. 415 13.1 overview................................................................................................................... ........ 415 13.1.1 features................................................................................................................ 4 15 13.1.2 block diagram..................................................................................................... 416 13.1.3 input pins ............................................................................................................. 41 7 13.1.4 register configuration......................................................................................... 418 13.2 register descriptions ...................................................................................................... .. 419 13.2.1 a/d data registers a to d (addra to addrd) ............................................. 419 13.2.2 a/d control/status register (adcsr) ............................................................... 420 13.2.3 a/d control register (adcr) ............................................................................ 422 13.3 cpu interface.............................................................................................................. ...... 423 13.4 operation .................................................................................................................. ........ 424 13.4.1 single mode (scan = 0) .................................................................................... 424 13.4.2 scan mode (scan = 1)....................................................................................... 426 13.4.3 input sampling and a/d conversion time ......................................................... 428 13.4.4 external trigger input timing............................................................................. 429 13.5 interrupts................................................................................................................. .......... 430 13.6 usage notes ................................................................................................................ ...... 430 section 14 ram .................................................................................................................. 435 14.1 overview................................................................................................................... ........ 435 14.1.1 block diagram..................................................................................................... 436 14.1.2 register configuration......................................................................................... 436 14.2 system control register (syscr) ................................................................................... 437 14.3 operation .................................................................................................................. ........ 438 section 15 rom .................................................................................................................. 439 15.1 overview................................................................................................................... ........ 439 15.2 overview of flash memory .............................................................................................. 440 15.2.1 features................................................................................................................ 4 40 15.2.2 block diagram..................................................................................................... 441 15.2.3 pin configuration................................................................................................. 442 15.2.4 register configuration......................................................................................... 442 15.3 register descriptions ...................................................................................................... .. 443 15.3.1 flash memory control register (flmcr).......................................................... 443 15.3.2 erase block register (ebr) ................................................................................ 447
rev.3.00 mar. 26, 2007 page xix of xxii rej09b0353-0300 15.3.3 ram control register (ramcr) ....................................................................... 449 15.3.4 flash memory status register (flmsr)............................................................. 451 15.4 on-board programming modes........................................................................................ 452 15.4.1 boot mode ........................................................................................................... 455 15.4.2 user program mode............................................................................................. 460 15.5 programming/erasing flash memory ............................................................................... 462 15.5.1 program mode ..................................................................................................... 463 15.5.2 program-verify mode.......................................................................................... 464 15.5.3 erase mode .......................................................................................................... 466 15.5.4 erase-verify mode............................................................................................... 466 15.6 flash memory protection.................................................................................................. 46 8 15.6.1 hardware protection ............................................................................................ 468 15.6.2 software protection.............................................................................................. 470 15.6.3 error protection.................................................................................................... 471 15.6.4 nmi input disable conditions............................................................................. 473 15.7 flash memory emulation by ram................................................................................... 474 15.8 flash memory prom mode............................................................................................. 475 15.8.1 prom mode setting............................................................................................ 475 15.8.2 memory map ....................................................................................................... 476 15.8.3 prom mode operation ....................................................................................... 476 15.8.4 memory read mode ............................................................................................ 479 15.8.5 auto-program mode ............................................................................................ 482 15.8.6 auto-erase mode ................................................................................................. 484 15.8.7 status read mode ................................................................................................ 485 15.8.8 prom mode transition time ............................................................................. 487 15.8.9 notes on memory programming.......................................................................... 488 15.9 notes on flash memory programming/erasing................................................................ 488 15.10 mask rom overview ....................................................................................................... 49 4 15.10.1 block diagram ..................................................................................................... 494 15.11 notes on ordering mask rom version chip................................................................... 495 section 16 clock pulse generator .................................................................................. 497 16.1 overview................................................................................................................... ........ 497 16.1.1 block diagram ..................................................................................................... 498 16.2 oscillator circuit......................................................................................................... ...... 498 16.2.1 connecting a crystal resonator........................................................................... 499 16.2.2 external clock input ............................................................................................ 501 16.3 duty adjustment circuit ................................................................................................... 5 04 16.4 prescalers ................................................................................................................. ......... 504 16.5 frequency divider.......................................................................................................... ... 504 16.5.1 register configuration......................................................................................... 504
rev.3.00 mar. 26, 2007 page xx of xxii rej09b0353-0300 16.5.2 division control register (divcr) .................................................................... 505 16.5.3 usage notes ......................................................................................................... 506 section 17 power-down state ......................................................................................... 507 17.1 overview................................................................................................................... ........ 507 17.2 register configuration..................................................................................................... . 509 17.2.1 system control register (syscr) ...................................................................... 509 17.2.2 module standby control register (mstcr) ...................................................... 511 17.3 sleep mode ................................................................................................................. ...... 513 17.3.1 transition to sleep mode..................................................................................... 513 17.3.2 exit from sleep mode.......................................................................................... 513 17.4 software standby mode.................................................................................................... 51 4 17.4.1 transition to software standby mode ................................................................. 514 17.4.2 exit from software standby mode ...................................................................... 514 17.4.3 selection of oscillator waiting time after exit from software standby mode .. 515 17.4.4 sample application of software standby mode.................................................. 516 17.4.5 usage note........................................................................................................... 516 17.5 hardware standby mode .................................................................................................. 517 17.5.1 transition to hardware standby mode................................................................ 517 17.5.2 exit from hardware standby mode ..................................................................... 517 17.5.3 timing for hardware standby mode ................................................................... 518 17.6 module standby function................................................................................................. 519 17.6.1 module standby timing ...................................................................................... 519 17.6.2 read/write in module standby ........................................................................... 519 17.6.3 usage notes ......................................................................................................... 519 17.7 system clock output disabling function......................................................................... 520 section 18 electrical characteristics .............................................................................. 521 18.1 electrical characteristics of mask rom version............................................................. 521 18.1.1 absolute maximum ratings ................................................................................ 521 18.1.2 dc characteristics ............................................................................................... 522 18.1.3 ac characteristics ............................................................................................... 530 18.1.4 a/d conversion characteristics........................................................................... 535 18.2 electrical characteristics of flash memory version ........................................................ 536 18.2.1 absolute maximum ratings ................................................................................ 536 18.2.2 dc characteristics ............................................................................................... 537 18.2.3 ac characteristics ............................................................................................... 543 18.2.4 a/d conversion characteristics........................................................................... 548 18.2.5 flash memory characteristics ............................................................................. 549 18.3 operational timing......................................................................................................... .. 552 18.3.1 bus timing .......................................................................................................... 552
rev.3.00 mar. 26, 2007 page xxi of xxii rej09b0353-0300 18.3.2 control signal timing ......................................................................................... 556 18.3.3 clock timing ....................................................................................................... 558 18.3.4 tpc and i/o port timing..................................................................................... 558 18.3.5 itu timing .......................................................................................................... 559 18.3.6 sci input/output timing ..................................................................................... 560 appendix a instruction set .............................................................................................. 561 a.1 instruction list ............................................................................................................ ...... 561 a.2 operation code maps ....................................................................................................... 57 7 a.3 number of states required for execution ........................................................................ 580 appendix b internal i/o register field ........................................................................ 590 b.1 addresses ................................................................................................................... ....... 590 b.2 function .................................................................................................................... ........ 597 appendix c i/o block diagrams .................................................................................... 655 c.1 port 1 block diagram ....................................................................................................... 6 55 c.2 port 2 block diagram ....................................................................................................... 6 56 c.3 port 3 block diagram ....................................................................................................... 6 57 c.4 port 5 block diagram ....................................................................................................... 6 58 c.5 port 6 block diagram ....................................................................................................... 6 59 c.6 port 7 block diagram ....................................................................................................... 6 61 c.7 port 8 block diagram ....................................................................................................... 6 62 c.8 port 9 block diagram ....................................................................................................... 6 64 c.9 port a block diagram....................................................................................................... 6 68 c.10 port b block diagram....................................................................................................... 671 appendix d pin states ....................................................................................................... 674 d.1 port states in each mode .................................................................................................. 67 4 d.2 pin states at reset ......................................................................................................... .... 676 appendix e timing of transition to and recovery from hardware standby mode ................................................................. 679 appendix f product lineup ............................................................................................. 680 appendix g package dimensions ................................................................................... 681
rev.3.00 mar. 26, 2007 page xxii of xxii rej09b0353-0300
section 1 overview rev.3.00 mar. 26, 2007 page 1 of 682 rej09b0353-0300 section 1 overview 1.1 overview the h8/3039 group comprises microcomputers (mcus) that integrate system supporting functions together with an h8/300h cpu core featuring an original renesas technology architecture. the h8/300h cpu has a 32-bit internal architecture with sixteen 16-bit general registers, and a concise, optimized instruction set designed for speed. it can address a 16-mbyte linear address space. its instruction set is upward-compatible at the object-code level with the h8/300 cpu, enabling easy porting of software from the h8/300 series. the on-chip system supporting functions include rom, ram, a 16-bit integrated timer unit (itu), a programmable timing pattern controller (tpc), a watchdog timer (wdt), a serial communication interface (sci), an a/d converter, i/o ports, and other facilities. the h8/3039 group consists of four models: the h8/3039 with 128 kbytes of rom and 4 kbytes of ram, the h8/3038 with 64 kbytes of rom and 2 kbytes of ram, the h8/3037 with 32 kbytes of rom and 1 kbytes of ram, and the h8/3036 with 16 kbytes of rom and 512 bytes of ram. the five mcu operating modes offer a choice of expanded mode, single-chip mode and address space size. in addition to the mask-rom version of the h8/3039 group, an f-ztat? version with an on- chip flash memory that can be freely programmed and reprogrammed by the user after the board is installed is also available. this version enables users to respond quickly and flexibly to changing application specifications, growing production volumes, and other conditions. table 1.1 summarizes the features of the h8/3039 group. note: f-ztat is a trademark of renesas technology corp.
section 1 overview rev.3.00 mar. 26, 2007 page 2 of 682 rej09b0353-0300 table 1.1 features feature description cpu upward-compatible with the h8/300 cpu at the object-code level general-register machine ? sixteen 16-bit general registers (also useable as sixteen 8-bit registers or eight 32-bit registers) high-speed operation ? maximum clock rate: 18 mhz ? add/subtract: 111 ns ? multiply/divide: 778 ns two cpu operating modes ? normal mode (64-kbyte address space) ? advanced mode (16-mbyte address space) instruction features ? 8/16/32-bit data transfer, arithmetic, and logic instructions ? signed and unsigned multiply instructions (8 bits 8 bits, 16 bits 16 bits) ? signed and unsigned divide instructions (16 bits 8 bits, 32 bits 16 bits) ? bit accumulator function ? bit manipulation instructions with register-indirect specification of bit positions
section 1 overview rev.3.00 mar. 26, 2007 page 3 of 682 rej09b0353-0300 feature description memory h8/3039 ? rom: 128 kbytes ? ram: 4 kbytes h8/3038 ? rom: 64 kbytes ? ram: 2 kbytes h8/3037 ? rom: 32 kbytes ? ram: 1 kbyte h8/3036 ? rom: 16 kbytes ? ram: 512 bytes interrupt controller ? five external interrupt pins: nmi, irq 0 , irq 1 , irq 4 , irq 5 ? 25 internal interrupts ? three selectable interrupt priority levels bus controller ? address space can be partitioned into eight areas, with independent bus specifications in each area ? two-state or three-state access selectable for each area ? selection of four wait modes 16-bit integrated timer unit (itu) ? five 16-bit timer channels, capable of processing up to 12 pulse outputs or 10 pulse inputs ? 16-bit timer counter (channels 0 to 4) ? two multiplexed output compare/input capture pins (channels 0 to 4) ? operation can be synchronized (channels 0 to 4) ? pwm mode available (channels 0 to 4) ? phase counting mode available (channel 2) ? buffering available (channels 3 and 4) ? reset-synchronized pwm mode available (channels 3 and 4) ? complementary pwm mode available (channels 3 and 4)
section 1 overview rev.3.00 mar. 26, 2007 page 4 of 682 rej09b0353-0300 feature description programmable timing pattern controller (tpc) ? maximum 15-bit pulse output, using itu as time base ? up to three 4-bit pulse output groups and one 3-bit pulse output group (or one 15-bit group, one 8-bit group, or one 7-bit group) ? non-overlap mode available watchdog timer (wdt), 1 channel ? reset signal can be generated by overflow ? reset signal can be output externally (however, not available with the f-ztat version.) ? usable as an interval timer serial communication interface (sci), 2 channels ? selection of asynchronous or synchronous mode ? full duplex: can transmit and receive simultaneously ? on-chip baud-rate generator ? smart card interface functions added (sci0 only) a/d converter ? resolution: 10 bits ? eight channels, with selection of single or scan mode ? variable analog conversion voltage range ? sample-and-hold function ? can be externally triggered i/o ports ? 55 input/output pins ? 8 input-only pins operating modes five mcu operating modes mode address space address pins bus width mode 1 1 mbyte a 0 to a 19 8 bits mode 3 16 mbytes a 23 to a 0 8 bits mode 5 1 mbyte a 0 to a 19 8 bits mode 6 64 kbytes ? ? mode 7 1 mbyte ? ? ? on-chip rom is disabled in modes 1 and 3 power-down state ? sleep mode ? software standby mode ? hardware standby mode ? module standby function ? programmable system clock frequency division
section 1 overview rev.3.00 mar. 26, 2007 page 5 of 682 rej09b0353-0300 feature description other features ? on-chip clock oscillator product lineup model (5 v) model (3 v) * package rom hd64f3039f hd64f3039vf 80-pin qfp (fp-80a) flash memory hd64f3039te hd64f3039vte 80-pin tqfp (tfp-80c) hd6433039f HD6433039VF 80-pin qfp (fp-80a) mask rom hd6433039te hd6433039vte 80-pin tqfp (tfp-80c) hd6433038f hd6433038vf 80-pin qfp (fp-80a) mask rom hd6433038te hd6433038vte 80-pin tqfp (tfp-80c) hd6433037f hd6433037vf 80-pin qfp (fp-80a) mask rom hd6433037te hd6433037vte 80-pin tqfp (tfp-80c) hd6433036f hd6433036vf 80-pin qfp (fp-80a) mask rom hd6433036te hd6433036vte 80-pin tqfp (tfp-80c) note: * there are two 3 v versions: one with v cc = 2.7 v to 5.5 v and = 2 to 8 mhz, and one with v cc = 3.0 v to 5.5 v and = 2 to 10 mhz. however, there is only one flash memory version, with v cc = 3.0 to 5.5 v and = 2 to 10 mhz.
section 1 overview rev.3.00 mar. 26, 2007 page 6 of 682 rej09b0353-0300 1.2 block diagram figure 1.1 shows an internal block diagram of the h8/3039 group. p7 7 /an 7 p7 6 /an 6 p7 5 /an 5 p7 4 /an 4 p7 3 /an 3 p7 2 /an 2 p7 1 /an 1 p7 0 /an 0 av cc av ss pa 7 /tp 7 /tiocb 2 /a 20 pa 6 /tp 6 /tioca 2 /a 21 pa 5 /tp 5 /tiocb 1 /a 22 pa 4 /tp 4 /tioca 1 /a 23 pa 3 /tp 3 /tiocb 0 /tclkd pa 2 /tp 2 /tioca 0 /tclkc pa 1 /tp 1 /tclkb pa 0 /tp 0 /tclka pb 7 /tp 15 / adtrg pb 5 /tp 13 /tocxb 4 pb 4 /tp 12 /tocxa 4 pb 3 /tp 11 /tiocb 4 pb 2 /tp 10 /tioca 4 pb 1 /tp 9 /tiocb 3 pb 0 /tp 8 /tioca 3 p2 7 /a 15 p2 6 /a 14 p2 5 /a 13 p2 4 /a 12 p2 3 /a 11 p2 2 /a 10 p2 1 /a 9 p2 0 /a 8 p1 7 /a 7 p1 6 /a 6 p1 5 /a 5 p1 4 /a 4 p1 3 /a 3 p1 2 /a 2 p1 1 /a 1 p1 0 /a 0 p9 5 /sck 1 / irq 5 p9 4 /sck 0 / irq 4 p9 3 /rxd 1 p9 2 /rxd 0 p9 1 /txd 1 p9 0 /txd 0 p5 3 /a 19 p5 2 /a 18 p5 1 /a 17 p5 0 /a 16 data bus (lower) bus controller clock osc. h8/300h cpu rom (flash memory, mask rom) ram 16-bit integrated timer unit (itu) programmable timing pattern controller (tpc) interrupt controller serial communication interface (sci) wr p6 4 / rd p6 3 / as p6 0 / wait p8 1 / irq 1 p8 0 / irq 0 md 1 md 0 extal xtal stby res reso /fwe * nmi v cc v cc v ss v ss v ss p3 7 /d 7 p3 6 /d 6 p3 5 /d 5 p3 4 /d 4 p3 3 /d 3 p3 2 /d 2 p3 1 /d 1 p3 0 /d 0 port 2 port 1 port 5 port 9 port 7 port a port b note: * mask rom: reso flash memory: fwe port 8 port 6 address bus data bus (upper) md 2 figure 1.1 block diagram
section 1 overview rev.3.00 mar. 26, 2007 page 7 of 682 rej09b0353-0300 1.3 pin description 1.3.1 pin arrangement figure 1.2 shows the pin arrangement of the h8/3039 group. p7 1 /an 1 p7 0 /an 0 av ss reso /fwe * p6 5 / wr p6 4 / rd p6 3 / as v cc xtal extal v ss nmi res stby wait p5 3 /a 19 p5 2 /a 18 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 tioca 3 /tp 8 /pb 0 tiocb 3 /tp 9 /pb 1 tioca 4 /tp 10 /pb 2 tiocb 4 /tp 11 /pb 3 tocxa 4 /tp 12 /pb 4 tocxb 4 /tp 13 /pb 5 md 2 adtrg /tp 15 /pb 7 txd 0 /p9 0 rxd 0 /p9 2 irq 4 /sck 0 /p9 4 v ss d 0 /p3 0 d 1 /p3 1 d 2 /p3 2 d 3 /p3 3 d 4 /p3 4 d 5 /p3 5 d 6 /p3 6 d 7 /p3 7 pa 7 /tp 7 /tiocb 2 /a 20 pa 6 /tp 6 /tioca 2 /a 21 pa 5 /tp 5 /tiocb 1 /a 22 pa 4 /tp 4 /tioca 1 /a 23 pa 3 /tp 3 /tiocb 0 /tclkd pa 2 /tp 2 /tioca 0 /tclkc pa 1 /tp 1 /tclkb pa 0 /tp 0 /tclka p9 5 /sck 1 / irq 5 p9 3 /rxd 1 p9 1 /txd 1 p8 1 / irq 1 p8 0 / irq 0 avcc p7 7 /an 7 p7 6 /an 6 p7 5 /an 5 p7 4 /an 4 p7 3 /an 3 p7 2 /an 2 v cc a 0 /p1 0 a 1 /p1 1 a 2 /p1 2 a 3 /p1 3 a 4 /p1 4 a 5 /p1 5 a 6 /p1 6 a 7 /p1 7 v ss a 8 /p2 0 a 9 /p2 1 a 10 /p2 2 a 11 /p2 3 a 12 /p2 4 a 13 /p2 5 a 14 /p2 6 a 15 /p2 7 a 16 /p5 0 a 17 /p5 1 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 top view (fp-80a, tfp-80c) note: * mask rom: reso flash memory: fwe figure 1.2 pin arrangement (fp-80a, tfp-80c top view)
section 1 overview rev.3.00 mar. 26, 2007 page 8 of 682 rej09b0353-0300 1.3.2 pin functions pin assignments in each mode table 1.2 lists the fp-80a and tfp-80c pin assignments in each mode. table 1.2 fp-80a and tfp-80c pin assignments in each mode pin name pin no. mode 1 mode 3 mode 5 mode 6 mode 7 prom mode flash memory 1pb 0 /tp 8 / tioca 3 pb 0 /tp 8 / tioca 3 pb 0 /tp 8 / tioca 3 pb 0 /tp 8 / tioca 3 pb 0 /tp 8 / tioca 3 nc 2pb 1 /tp 9 / tiocb 3 pb 1 /tp 9 / tiocb 3 pb 1 /tp 9 / tiocb 3 pb 1 /tp 9 / tiocb 3 pb 1 /tp 9 / tiocb 3 nc 3pb 2 /tp 10 / tioca 4 pb 2 /tp 10 / tioca 4 pb 2 /tp 10 / tioca 4 pb 2 /tp 10 / tioca 4 pb 2 /tp 10 / tioca 4 nc 4pb 3 /tp 11 / tiocb 4 pb 3 /tp 11 / tiocb 4 pb 3 /tp 11 / tiocb 4 pb 3 /tp 11 / tiocb 4 pb 3 /tp 11 / tiocb 4 nc 5pb 4 /tp 12 / tocxa 4 pb 4 /tp 12 / tocxa 4 pb 4 /tp 12 / tocxa 4 pb 4 /tp 12 / tocxa 4 pb 4 /tp 12 / tocxa 4 nc 6pb 5 /tp 13 / tocxb 4 pb 5 /tp 13 / tocxb 4 pb 5 /tp 13 / tocxb 4 pb 5 /tp 13 / tocxb 4 pb 5 /tp 13 / tocxb 4 nc 7md 2 md 2 md 2 md 2 md 2 v ss 8pb 7 /tp 15 / adtrg pb 7 /tp 15 / adtrg pb 7 /tp 15 / adtrg pb 7 /tp 15 / adtrg pb 7 /tp 15 / adtrg nc 9p9 0 /txd 0 p9 0 /txd 0 p9 0 /txd 0 p9 0 /txd 0 p9 0 /txd 0 nc 10 p9 2 /rxd 0 p9 2 /rxd 0 p9 2 /rxd 0 p9 2 /rxd 0 p9 2 /rxd 0 v ss 11 p9 4 /sck 0 / irq 4 p9 4 /sck 0 / irq 4 p9 4 /sck 0 / irq 4 p9 4 /sck 0 / irq 4 p9 4 /sck 0 / irq 4 nc 12 v ss v ss v ss v ss v ss v ss 13 d 0 d 0 d 0 p3 0 p3 0 i/o 0 14 d 1 d 1 d 1 p3 1 p3 1 i/o 1 15 d 2 d 2 d 2 p3 2 p3 2 i/o 2 16 d 3 d 3 d 3 p3 3 p3 3 i/o 3 17 d 4 d 4 d 4 p3 4 p3 4 i/o 4
section 1 overview rev.3.00 mar. 26, 2007 page 9 of 682 rej09b0353-0300 pin name pin no. mode 1 mode 3 mode 5 mode 6 mode 7 prom mode flash memory 18 d 5 d 5 d 5 p3 5 p3 5 i/o 5 19 d 6 d 6 d 6 p3 6 p3 6 i/o 6 20 d 7 d 7 d 7 p3 7 p3 7 i/o 7 21 v cc v cc v cc v cc v cc v cc 22 a 0 a 0 p1 0 /a 0 p1 0 p1 0 a 0 23 a 1 a 1 p1 1 /a 1 p1 1 p1 1 a 1 24 a 2 a 2 p1 2 /a 2 p1 2 p1 2 a 2 25 a 3 a 3 p1 3 /a 3 p1 3 p1 3 a 3 26 a 4 a 4 p1 4 /a 4 p1 4 p1 4 a 4 27 a 5 a 5 p1 5 /a 5 p1 5 p1 5 a 5 28 a 6 a 6 p1 6 /a 6 p1 6 p1 6 a 6 29 a 7 a 7 p1 7 /a 7 p1 7 p1 7 a 7 30 v ss v ss v ss v ss v ss v ss 31 a 8 a 8 p2 0 /a 8 p2 0 p2 0 a 8 32 a 9 a 9 p2 1 /a 9 p2 1 p2 1 a 9 33 a 10 a 10 p2 2 /a 10 p2 2 p2 2 a 10 34 a 11 a 11 p2 3 /a 11 p2 3 p2 3 a 11 35 a 12 a 12 p2 4 /a 12 p2 4 p2 4 a 12 36 a 13 a 13 p2 5 /a 13 p2 5 p2 5 a 13 37 a 14 a 14 p2 6 /a 14 p2 6 p2 6 a 14 38 a 15 a 15 p2 7 /a 15 p2 7 p2 7 a 15 39 a 16 a 16 p5 0 /a 16 p5 0 p5 0 a 16 40 a 17 a 17 p5 1 /a 17 p5 1 p5 1 v ss 41 a 18 a 18 p5 2 /a 18 p5 2 p5 2 v ss 42 a 19 a 19 p5 3 /a 19 p5 3 p5 3 v ss 43 p6 0 / wait p6 0 / wait p6 0 / wait p6 0 p6 0 nc 44 md 0 md 0 md 0 md 0 md 0 v ss 45 md 1 md 1 md 1 md 1 md 1 v ss 46 ????
section 1 overview rev.3.00 mar. 26, 2007 page 10 of 682 rej09b0353-0300 pin name pin no. mode 1 mode 3 mode 5 mode 6 mode 7 prom mode flash memory 47 stby stby stby stby stby v cc 48 res res res res res res 49 nmi nmi nmi nmi nmi v cc 50 v ss v ss v ss v ss v ss v ss 51 extal extal extal extal extal extal 52 xtal xtal xtal xtal xtal xtal 53 v cc v cc v cc v cc v cc v cc 54 as as as p6 3 p6 3 nc 55 rd rd rd p6 4 p6 4 nc 56 wr wr wr p6 5 p6 5 v cc 57 reso / fwe * reso / fwe * reso / fwe * reso / fwe * reso / fwe * fwe 58 av ss av ss av ss av ss av ss v ss 59 p7 0 /an 0 p7 0 /an 0 p7 0 /an 0 p7 0 /an 0 p7 0 /an 0 nc 60 p7 1 /an 1 p7 1 /an 1 p7 1 /an 1 p7 1 /an 1 p7 1 /an 1 nc 61 p7 2 /an 2 p7 2 /an 2 p7 2 /an 2 p7 2 /an 2 p7 2 /an 2 nc 62 p7 3 /an 3 p7 3 /an 3 p7 3 /an 3 p7 3 /an 3 p7 3 /an 3 nc 63 p7 4 /an 4 p7 4 /an 4 p7 4 /an 4 p7 4 /an 4 p7 4 /an 4 nc 64 p7 5 /an 5 p7 5 /an 5 p7 5 /an 5 p7 5 /an 5 p7 5 /an 5 nc 65 p7 6 /an 6 p7 6 /an 6 p7 6 /an 6 p7 6 /an 6 p7 6 /an 6 nc 66 p7 7 /an 7 p7 7 /an 7 p7 7 /an 7 p7 7 /an 7 p7 7 /an 7 nc 67 av cc av cc av cc av cc av cc v cc 68 p8 0 / irq 0 p8 0 / irq 0 p8 0 / irq 0 p8 0 / irq 0 p8 0 / irq 0 v ss 69 p8 1 / irq 1 p8 1 / irq 1 p8 1 / irq 1 p8 1 / irq 1 p8 1 / irq 1 v ss 70 p9 1 /txd 1 p9 1 /txd 1 p9 1 /txd 1 p9 1 /txd 1 p9 1 /txd 1 nc 71 p9 3 /rxd 1 p9 3 /rxd 1 p9 3 /rxd 1 p9 3 /rxd 1 p9 3 /rxd 1 nc 72 p9 5 /sck 1 / irq 5 p9 5 /sck 1 / irq 5 p9 5 /sck 1 / irq 5 p9 5 /sck 1 / irq 5 p9 5 /sck 1 / irq 5 v cc 73 pa 0 /tp 0 / tclka pa 0 /tp 0 / tclka pa 0 /tp 0 / tclka pa 0 /tp 0 / tclka pa 0 /tp 0 / tclka ce
section 1 overview rev.3.00 mar. 26, 2007 page 11 of 682 rej09b0353-0300 pin name pin no. mode 1 mode 3 mode 5 mode 6 mode 7 prom mode flash memory 74 pa 1 /tp 1 / tclkb pa 1 /tp 1 / tclkb pa 1 /tp 1 / tclkb pa 1 /tp 1 / tclkb pa 1 /tp 1 / tclkb oe 75 pa 2 /tp 2 / tioca 0 / tclkc pa 2 /tp 2 / tioca 0 / tclkc pa 2 /tp 2 / tioca 0 / tclkc pa 2 /tp 2 / tioca 0 / tclkc pa 2 /tp 2 / tioca 0 / tclkc we 76 pa 3 /tp 3 / tiocb 0 / tclkd pa 3 /tp 3 / tiocb 0 / tclkd pa 3 /tp 3 / tiocb 0 / tclkd pa 3 /tp 3 / tiocb 0 / tclkd pa 3 /tp 3 / tiocb 0 / tclkd nc 77 pa 4 /tp 4 / tioca 1 pa 4 /tp 4 / tioca 1 /a 23 pa 4 /tp 4 / tioca 1 pa 4 /tp 4 / tioca 1 pa 4 /tp 4 / tioca 1 nc 78 pa 5 /tp 5 / tiocb 1 pa 5 /tp 5 / tiocb 1 /a 22 pa 5 /tp 5 / tiocb 1 pa 5 /tp 5 / tiocb 1 pa 5 /tp 5 / tiocb 1 nc 79 pa 6 /tp 6 / tioca 2 pa 6 /tp 6 / tioca 2 /a 21 pa 6 /tp 6 / tioca 2 pa 6 /tp 6 / tioca 2 pa 6 /tp 6 / tioca 2 nc 80 pa 7 /tp 7 / tiocb 2 a 20 pa 7 /tp 7 / tiocb 2 pa 7 /tp 7 / tiocb 2 pa 7 /tp 7 / tiocb 2 nc notes: pins marked nc should be left unconnected. for details about prom mode see section 15, rom. * mask rom: reso flash memory: fwe
section 1 overview rev.3.00 mar. 26, 2007 page 12 of 682 rej09b0353-0300 1.4 pin functions table 1.3 summarizes the pin functions. table 1.3 pin functions type symbol pin no. i/o name and function power v cc 21, 53 input power: for connection to the power supply. connect all v cc pins to the system power supply. v ss 12, 30, 50 input ground: for connection to ground (0 v). connect all v ss pins to the 0-v system power supply. clock xtal 52 input for connection to a crystal resonator for examples of crystal resonator and external clock input, see section 16, clock pulse generator. extal 51 input for connection to a crystal resonator or input of an external clock signal. for examples of crystal resonator and external clock input, see section 16, clock pulse generator. mode 2 to mode 0: for setting the operating mode, as follows. these pins should not be changed during operation. md 2 md 1 md 0 operating mode 000 ? 0 0 1 mode 1 010 ? 0 1 1 mode 3 100 ? 1 0 1 mode 5 1 1 0 mode 6 1 1 1 mode 7
section 1 overview rev.3.00 mar. 26, 2007 page 13 of 682 rej09b0353-0300 type symbol pin no. i/o name and function system control res 48 input reset input: when driven low, this pin resets the chip reso / fwe 57 output/ input reset output (mask rom version): outputs wdt-generated reset signal to an external device. write enable signal (f-ztat version): flash memory write control signal. stby 47 input standby: when driven low, this pin forces a transition to hardware standby mode interrupts nmi 49 input nonmaskable interrupt: requests a nonmaskable interrupt irq 5 , irq 4 irq 1 , irq 0 72, 11, 69, 68 input interrupt request 5, 4, 1, 0: maskable interrupt request pins address bus a 23 to a 20 , a 19 to a 8 , a 7 to a 0 77 to 80, 42 to 31, 29 to 22 output address bus: outputs address signals data bus d 7 to d 0 20 to 13 input/ output data bus: bidirectional data bus bus control as 54 output address strobe: goes low to indicate valid address output on the address bus rd 55 output read: goes low to indicate reading from the external address space. wr 56 output write: goes low to indicate writing to the external address space indicates valid data on the data bus. wait 43 input wait: requests insertion of wait states in bus cycles during access to the external address space. tclkd to tclka 76 to 73 input clock input a to d: external clock inputs 16-bit integrated timer unit (itu) tioca 4 to tioca 0 3, 1, 79, 77, 75 input/ output input capture/output compare a4 to a0: gra4 to gra0 output compare or input capture, or pwm output tiocb 4 to tiocb 0 4, 2, 80, 78, 76 input/ output input capture/output compare b4 to b0 grb4 to grb0 output compare or input capture, or pwm output tocxa 4 5 output output compare xa4: pwm output tocxb 4 6 output output compare xb4: pwm output
section 1 overview rev.3.00 mar. 26, 2007 page 14 of 682 rej09b0353-0300 type symbol pin no. i/o name and function programmable timing pattern controller (tpc) tp 15 , tp 13 to tp 0 8, 6 to 1 80 to 73 output tpc output 15, 13 to 0 : pulse output txd 1 , txd 0 70, 9 output transmit data :(channels 0 and 1): sci data output serial com- munication interface (sci) rxd 1 , rxd 0 71, 10 input receive data: (channels 0 and 1): sci data input sck 1 , sck 0 72, 11 input/ output serial clock: (channels 0 and 1): sci clock input/output an 7 to an 0 66 to 59 input analog 7 to 0: analog input pins a/d converter adtrg 8 input a/d trigger: external trigger input for starting a/d conversion av cc 67 input power supply pin and reference voltage input pin for the a/d converter. connect to the system power supply when not using the a/d converter. av ss 58 input ground pin for the a/d converter. connect to system power-supply (0 v). i/o ports p1 7 to p1 0 29 to 22 input/ output port 1: eight input/output pins. the direction of each pin can be selected in the port 1 data direction register (p1ddr). p2 7 to p2 0 38 to 31 input/ output port 2: eight input/output pins. the direction of each pin can be selected in the port 2 data direction register (p2ddr). p3 7 to p3 0 20 to 13 input/ output port 3: eight input/output pins. the direction of each pin can be selected in the port 3 data direction register (p3ddr). p5 3 to p5 0 42 to 39 input/ output port 5: four input/output pins. the direction of each pin can be selected in the port 5 data direction register (p5ddr). p6 5 to p6 3 , p6 0 56 to 54, 43 input/ output port 6: four input/output pins. the direction of each pin can be selected in the port 6 data direction register (p6ddr). p7 7 to p7 0 66 to 59 input port 7: eight input pins p8 1 , p8 0 69, 68 input/ output port 8: two input/output pins. the direction of each pin can be selected in the port 8 data direction register (p8ddr).
section 1 overview rev.3.00 mar. 26, 2007 page 15 of 682 rej09b0353-0300 type symbol pin no. i/o name and function i/o ports p9 5 to p9 0 72, 11 71, 10 70, 9 input/ output port 9: six input/output pins. the direction of each pin can be selected in the port 9 data direction register (p9ddr). pa 7 to pa 0 80 to 73 input/ output port a: eight input/output pins. the direction of each pin can be selected in the port a data direction register (paddr). pb 7 , pb 5 to pb 0 8, 6to1 input/ output port b: seven input/output pins. the direction of each pin can be selected in the port b data direction register (pbddr).
section 1 overview rev.3.00 mar. 26, 2007 page 16 of 682 rej09b0353-0300
section 2 cpu rev.3.00 mar. 26, 2007 page 17 of 682 rej09b0353-0300 section 2 cpu 2.1 overview the h8/300h cpu is a high-speed central processing unit with an internal 32-bit architecture that is upward-compatible with the h8/300 cpu. the h8/300h cpu has sixteen 16-bit general registers, can address a 16-mbyte linear address space, and is ideal for realtime control. 2.1.1 features the h8/300h cpu has the following features. ? upward compatibility with h8/300 cpu can execute h8/300 series object programs without alteration ? general-register architecture sixteen 16-bit general registers (also usable as sixteen 8-bit registers or eight 32-bit registers) ? sixty-two basic instructions ? 8/16/32-bit arithmetic and logic instructions ? multiply and divide instructions ? powerful bit-manipulation instructions ? eight addressing modes ? register direct [rn] ? register indirect [@ern] ? register indirect with displacement [@(d:16, ern) or @(d:24, ern)] ? register indirect with post-increment or pre-decrement [@ern+ or @?ern] ? absolute address [@aa:8, @aa:16, or @aa:24] ? immediate [#xx:8, #xx:16, or #xx:32] ? program-counter relative [@(d:8, pc) or @(d:16, pc)] ? memory indirect [@@aa:8] ? 16-mbyte linear address space ? high-speed operation ? all frequently-used instructions execute in two to four states ? maximum clock frequency: 18 mhz ? 8/16/32-bit register-register add/subtract: 111 ns ? 8 8-bit register-register multiply: 778 ns ? 16 8-bit register-register divide: 778 ns
section 2 cpu rev.3.00 mar. 26, 2007 page 18 of 682 rej09b0353-0300 ? 16 16-bit register-register multiply: 1222 ns ? 32 16-bit register-register divide: 1222 ns ? two cpu operating modes ? normal mode ? advanced mode ? low-power mode transition to power-down state by sleep instruction 2.1.2 differences from h8/300 cpu in comparison to the h8/300 cpu, the h8/300h has the following enhancements. ? more general registers eight 16-bit registers have been added. ? expanded address space ? advanced mode supports a maximum 16-mbyte address space. ? normal mode supports the same 64-kbyte address space as the h8/300 cpu. ? enhanced addressing the addressing modes have been enhanced to make effective use of the 16-mbyte address space. ? enhanced instructions ? data transfer, arithmetic, and logic instructions can operate on 32-bit data. ? signed multiply/divide instructions and other instructions have been added.
section 2 cpu rev.3.00 mar. 26, 2007 page 19 of 682 rej09b0353-0300 2.2 cpu operating modes the h8/300h cpu has two operating modes: normal and advanced. normal mode supports a maximum 64-kbyte address space. advanced mode supports up to 16 mbytes. see figure 2.1. unless specified otherwise, all descriptions in this manual refer to advanced mode. cpu operating modes normal mode maximum 64 kbytes, program and data areas combined maximum 16 mbytes, program and data areas combined advanced mode figure 2.1 cpu operating modes
section 2 cpu rev.3.00 mar. 26, 2007 page 20 of 682 rej09b0353-0300 2.3 address space the maximum address space of the h8/300h cpu is 16 mbytes. this lsi allows selection of a normal mode and advanced mode 1-mbyte mode or 16-mbyte mode for the address space depending on the mcu operation mode. figure 2.2 shows the address ranges of the h8/3039 group. for further details see section 3.6, memory map in each operating mode. the 1-mbyte operating mode uses 20-bit addressing. the upper 4 bits of effective addresses are ignored. h'000000 h'ffffff (b) 16-mbyte mode (a) 1-mbyte mode 2. advanced mode 1. normal mode (64-kbyte mode) h'00000 h'fffff h'0000 h'ffff figure 2.2 memory map
section 2 cpu rev.3.00 mar. 26, 2007 page 21 of 682 rej09b0353-0300 2.4 register configuration 2.4.1 overview the h8/300h cpu has the internal registers shown in figure 2.3. there are two types of registers: general registers and control registers. er0 er1 er2 er3 er4 er5 er6 er7 e0 e1 e2 e3 e4 e5 e6 e7 r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l 0 7 0 7 0 15 (sp) 23 0 pc 7 ccr 6543210 iuihunzvc general registers (ern) control registers (cr) legend: sp: pc: ccr: i: ui: h: u: n: z: v: c: stack pointer program counter condition code register interrupt mask bit user bit or interrupt mask bit half-carry flag user bit negative flag zero flag overflow flag carry flag figure 2.3 cpu registers
section 2 cpu rev.3.00 mar. 26, 2007 page 22 of 682 rej09b0353-0300 2.4.2 general registers the h8/300h cpu has eight 32-bit general registers. these general registers are all functionally alike and can be used without distinction between data registers and address registers. when a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. when the general registers are used as 32-bit registers or as address registers, they are designated by the letters er (er0 to er7). the er registers divide into 16-bit general registers designated by the letters e (e0 to e7) and r (r0 to r7). these registers are functionally equivalent, providing a maximum sixteen 16-bit registers. the e registers (e0 to e7) are also referred to as extended registers. the r registers divide into 8-bit general registers designated by the letters rh (r0h to r7h) and rl (r0l to r7l). these registers are functionally equivalent, providing a maximum sixteen 8-bit registers. figure 2.4 illustrates the usage of the general registers. the usage of each register can be selected independently.  address registers  32-bit registers  16-bit registers  8-bit registers er registers er0 to er7 e registers (extended registers) e0 to e7 r registers r0 to r7 rh registers r0h to r7h rl registers r0l to r7l figure 2.4 usage of general registers
section 2 cpu rev.3.00 mar. 26, 2007 page 23 of 682 rej09b0353-0300 general register er7 has the function of stack pointer (sp) in addition to its general-register function, and is used implicitly in exception handling and subroutine calls. figure 2.5 shows the stack. free area stack area sp (er7) figure 2.5 stack 2.4.3 control registers the control registers are the 24-bit program counter (pc) and the 8-bit condition code register (ccr). program counter (pc) this 24-bit counter indicates the address of the next instruction the cpu will execute. the length of all cpu instructions is 2 bytes (one word) or a multiple of 2 bytes, so the least significant pc bit is ignored. when an instruction is fetched, the least significant pc bit is regarded as 0. condition code register (ccr) this 8-bit register contains internal cpu status information, including the interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. bit 7?interrupt mask bit (i): masks interrupts other than nmi when set to 1. nmi is accepted regardless of the i bit setting. the i bit is set to 1 at the start of an exception-handling sequence. bit 6?user bit or interrupt mask bit (ui): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. this bit can also be used as an interrupt mask bit. for details see section 5, interrupt controller.
section 2 cpu rev.3.00 mar. 26, 2007 page 24 of 682 rej09b0353-0300 bit 5?half-carry flag (h): when the add.b, addx.b, sub.b, subx.b, cmp.b, or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and cleared to 0 otherwise. when the add.w, sub.w, cmp.w, or neg.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and cleared to 0 otherwise. when the add.l, sub.l, cmp.l, or neg.l instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 27, and cleared to 0 otherwise. bit 4?user bit (u): can be written and read by software using the ldc, stc, andc, orc, and xorc instructions. bit 3?negative flag (n): indicates the most significant bit (sign bit) of data. bit 2?zero flag (z): set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data. bit 1?overflow flag (v): set to 1 when an arithmetic overflow occurs, and cleared to 0 at other times. bit 0?carry flag (c): set to 1 when a carry occurs, and cleared to 0 otherwise. used by: ? add instructions, to indicate a carry ? subtract instructions, to indicate a borrow ? shift and rotate instructions, to store the value shifted out of the end bit the carry flag is also used as a bit accumulator by bit manipulation instructions. some instructions leave flag bits unchanged. operations can be performed on ccr by the ldc, stc, andc, orc, and xorc instructions. the n, z, v, and c flags are used by conditional branch (bcc) instructions. for the action of each instruction on the flag bits, see appendix a.1, instruction list. for the i and ui bits, see section 5, interrupt controller. 2.4.4 initial cpu register values in reset exception handling, pc is initialized to a value loaded from the vector table, and the i bit in ccr is set to 1. the other ccr bits and the general registers are not initialized. in particular, the stack pointer (er7) is not initialized. the stack pointer must therefore be initialized by an mov.l instruction executed immediately after a reset.
section 2 cpu rev.3.00 mar. 26, 2007 page 25 of 682 rej09b0353-0300 2.5 data formats the h8/300h cpu can process 1-bit, 4-bit (bcd), 8-bit (byte), 16-bit (word), and 32-bit (longword) data. bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, ?, 7) of byte operand data. the daa and das decimal-adjust instructions treat byte data as two digits of 4-bit bcd data. 2.5.1 general register data formats figures 2.6 and 2.7 show the data formats in general registers. 7 rnh rnl rnh rnl rnh rnl 1-bit data 1-bit data 4-bit bcd data 4-bit bcd data byte data byte data 6543210 70 don't care 76543210 70 don't care don't care 70 43 lower digit upper digit 7 43 lower digit upper digit don't care 0 70 don't care msb lsb don't care 70 msb lsb data type data format general register legend: rnh: rnl: general register rh general register rl figure 2.6 general register data formats
section 2 cpu rev.3.00 mar. 26, 2007 page 26 of 682 rej09b0353-0300 rn en ern word data word data longword data general register data type data format 15 0 msb lsb 15 0 msb lsb 31 16 msb 15 0 lsb legend: ern: en: rn: msb: lsb: general register general register e general register r most significant bit least significant bit figure 2.7 general register data formats
section 2 cpu rev.3.00 mar. 26, 2007 page 27 of 682 rej09b0353-0300 2.5.2 memory data formats figure 2.8 shows the data formats on memory. the h8/300h cpu can access word data and longword data on memory, but word or longword data must begin at an even address. if an attempt is made to access word or longword data at an odd address, no address error occurs but the least significant bit of the address is regarded as 0, so the access starts at the preceding address. this also applies to instruction fetches. 76543210 address l address l lsb msb msb lsb 70 msb lsb 1-bit data byte data word data longword data address data type data format address 2m address 2m + 1 address 2n address 2n + 1 address 2n + 2 address 2n + 3 figure 2.8 memory data formats when er7 (sp) is used as an address register to access the stack, the operand size should be word size or longword size.
section 2 cpu rev.3.00 mar. 26, 2007 page 28 of 682 rej09b0353-0300 2.6 instruction set 2.6.1 instruction set overview the h8/300h cpu has 62 types of instructions, which are classified as shown in table 2.1. table 2.1 instruction classification function instruction types data transfer mov, push * 1 , pop * 1 , movtpe * 2 , movfpe * 2 3 arithmetic operations add, sub, addx, subx, inc, dec, adds, subs, daa, das, mulxu, mulxs, divxu, divxs, cmp, neg, exts, extu 18 logic operations and, or, xor, not 4 shift operations shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr 8 bit manipulation bset, bclr, bnot, btst, band, biand, bor, bior, bxor, bixor, bld, bild, bst, bist 14 branch bcc * 3 , jmp, bsr, jsr, rts 5 system control trapa, rte, sleep, ldc, stc, andc, orc, xorc, nop 9 block data transfer eepmov 1 total 62 types notes: 1. pop.w rn is identical to mov.w @sp+, rn. push.w rn is identical to mov.w rn, @ ? sp. pop.l ern is identical to mov.l @sp+, rn. push.l ern is identical to mov.l rn, @ ? sp. 2. these instructions are not available on the h8/3039 group. 3. bcc is a generic branching instruction.
section 2 cpu rev.3.00 mar. 26, 2007 page 29 of 682 rej09b0353-0300 2.6.2 instructions and addressing modes table 2.2 indicates the instructions available in the h8/300h cpu. table 2.2 instructions and addressing modes addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:24, ern) @ern+/@?ern @aa:8 @aa:16 @aa:24 @(d:8, pc) @(d:16,pc) @@aa:8 implied mov bwl bwl bwl bwl bwl bwl b bwl bwl ???? pop, push ???????????? wl data transfer movfpe, movtpe ??????? b ????? add, cmp bwl bwl ??????????? sub wl bwl ??????????? addx, subx b b ??????????? adds, subs ? l ??????????? inc, dec ? bwl ??????????? daa, das ? b ??????????? mulxu, mulxs, divxu, divxs ? bw ??????????? neg ? bwl ??????????? arithmetic operations extu, exts ? wl ??????????? and, or, xor bwl bwl ??????????? logic operations not ? bwl ??????????? shift instructions ? bwl ??????????? bit manipulation ? bb ??? b ?????? branch bcc, bsr ????????? ?? jmp, jsr ?? ????? ?? ? rts ????????????
section 2 cpu rev.3.00 mar. 26, 2007 page 30 of 682 rej09b0353-0300 addressing modes function instruction #xx rn @ern @(d:16,ern) @(d:24, ern) @ern+/@?ern @aa:8 @aa:16 @aa:24 @(d:8, pc) @(d:16,pc) @@aa:8 implied trapa ???????????? system control rte ???????????? sleep ???????????? ldc b b wwww ? ww ???? stc ? b wwww ? ww ???? andc, orc, xorc b ???????????? nop ???????????? block data transfer ???????????? bw legend: b: byte w: word l: longword
section 2 cpu rev.3.00 mar. 26, 2007 page 31 of 682 rej09b0353-0300 2.6.3 tables of instructions classified by function tables 2.3 to 2.10 summarize the instructions in each functional category. the operation notation used in these tables is defined as follows. operation notation rd general register (destination) * rs general register (source) * rn general register * ern general register (32-bit register or address register) (ead) destination operand (eas) source operand ccr condition code register n n (negative) flag of ccr z z (zero) flag of ccr v v (overflow) flag of ccr c c (carry) flag of ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition ? subtraction ? not (logical complement) :3/:8/:16/:24 3-, 8-, 16-, or 24-bit length note: * general registers include 8-bit registers (r0h to r7h, r0l to r7l), 16-bit registers (r0 to r7, e0 to e7), and 32-bit data or address registers (er0 to er7).
section 2 cpu rev.3.00 mar. 26, 2007 page 32 of 682 rej09b0353-0300 table 2.3 data transfer instructions instruction size * function mov b/w/l (eas) ? sp pushes a general register onto the stack. push.w rn is identical to mov.w rn, @ ? sp. similarly, push.l ern is identical to mov.l ern, @ ? sp. note: * size refers to the operand size. b: byte w: word l: longword
section 2 cpu rev.3.00 mar. 26, 2007 page 33 of 682 rej09b0353-0300 table 2.4 arithmetic operation instructions instruction size * function add, sub b/w/l rd rs * size refers to the operand size. b: byte w: word l: longword
section 2 cpu rev.3.00 mar. 26, 2007 page 34 of 682 rej09b0353-0300 instruction size * function divxu b/w rd rs 8 bits 16 bits rs 8 bits 16 bits ? rs, rd ? #imm compares data in a general register with data in another general register or with immediate data, and sets ccr according to the result. neg b/w/l 0 ? rd * size refers to the operand size. b: byte w: word l: longword
section 2 cpu rev.3.00 mar. 26, 2007 page 35 of 682 rej09b0353-0300 table 2.5 logic operation instructions instruction size * function and b/w/l rd ? rd * size refers to the operand size. b: byte w: word l: longword table 2.6 shift instructions instruction size * function shal, shar b/w/l rd (shift) * size refers to the operand size. b: byte w: word l: longword
section 2 cpu rev.3.00 mar. 26, 2007 page 36 of 682 rej09b0353-0300 table 2.7 bit manipulation instructions instruction size * function bset b 1 ? ( of ) ? ( of ) ? ( of )] ? ( of )]
section 2 cpu rev.3.00 mar. 26, 2007 page 37 of 682 rej09b0353-0300 instruction size * function bxor b c ? ( of )] ? ( of ) ? ( of ) transfers the inverse of the carry flag value to a specified bit in a general register or memory operand. the bit number is specified by 3-bit immediate data. note: * size refers to the operand size. b: byte
section 2 cpu rev.3.00 mar. 26, 2007 page 38 of 682 rej09b0353-0300 table 2.8 branching instructions instruction size function bcc ? branches to a specified address if a specified condition is true. the branching conditions are listed below. mnemonic description condition bra (bt) always (true) always brn (bf) never (false) never bhi high c ? branches unconditionally to a specified address bsr ? branches to a subroutine at a specified address jsr ? branches to a subroutine at a specified address rts ? returns from a subroutine
section 2 cpu rev.3.00 mar. 26, 2007 page 39 of 682 rej09b0353-0300 table 2.9 system control instructions instruction size * function trapa ? starts trap-instruction exception handling rte ? returns from an exception-handling routine sleep ? causes a transition to the power-down state ldc b/w (eas) ? pc + 2 * size refers to the operand size. b: byte w: word
section 2 cpu rev.3.00 mar. 26, 2007 page 40 of 682 rej09b0353-0300 table 2.10 block transfer instruction instruction size function eepmov.b ? if r4l ? 1 ? 1 2.6.4 basic instruction formats the h8/300h instructions consist of 2-byte (1-word) units. an instruction consists of an operation field (op field), a register field (r field), an effective address extension (ea field), and a condition field (cc). operation field: indicates the function of the instruction, the addressing mode, and the operation to be carried out on the operand. the operation field always includes the first 4 bits of the instruction. some instructions have two operation fields. register field: specifies a general register. address registers are specified by 3 bits, data registers by 3 bits or 4 bits. some instructions have two register fields. some have no register field. effective address extension: eight, 16, or 32 bits specifying immediate data, an absolute address, or a displacement. a 24-bit address or displacement is treated as 32-bit data in which the first 8 bits are 0 (h'00). condition field: specifies the branching condition of bcc instructions.
section 2 cpu rev.3.00 mar. 26, 2007 page 41 of 682 rej09b0353-0300 figure 2.9 shows examples of instruction formats. op nop, rts, etc. op rn rm op rn rm ea (disp) operation field only add.b rn, rm, etc. operation field and register fields mov.b @(d:16, rn), rm operation field, register fields, and effective address extension bra d:8 operation field, effective address extension, and condition field op cc ea (disp) figure 2.9 instruction formats 2.6.5 notes on use of bit manipulation instructions the bset, bclr, bnot, bst, and bist instructions read a byte of data, modify a bit in the byte, then write the byte back. care is required when these instructions are used to access registers with write-only bits, or to access ports. the bclr instruction can be used to clear flags in the on-chip registers. in an interrupt-handling routine, for example, if it is known that the flag is set to 1, it is not necessary to read the flag ahead of time. 2.7 addressing modes and effective address calculation 2.7.1 addressing modes the h8/300h cpu supports the eight addressing modes listed in table 2.11. each instruction uses a subset of these addressing modes. arithmetic and logic instructions can use the register direct and immediate modes. data transfer instructions can use all addressing modes except program- counter relative and memory indirect. bit manipulation instructions use register direct, register indirect, or absolute (@aa:8) addressing mode to specify an operand, and register direct (bset,
section 2 cpu rev.3.00 mar. 26, 2007 page 42 of 682 rej09b0353-0300 bclr, bnot, and btst instructions) or immediate (3-bit) addressing mode to specify a bit number in the operand. table 2.11 addressing modes no. addressing mode symbol 1 register direct rn 2 register indirect @ern 3 register indirect with displacement @(d:16, ern)/@d:24, ern) 4 register indirect with post-increment register indirect with pre-decrement @ern+ @ ? ern 5 absolute address @aa:8/@aa:16/@aa:24 6 immediate #xx:8/#xx:16/#xx:32 7 program-counter relative @(d:8, pc)/@(d:16, pc) 8 memory indirect @@aa:8 1. register direct?rn the register field of the instruction code specifies an 8-, 16-, or 32-bit register containing the operand. r0h to r7h and r0l to r7l can be specified as 8-bit registers. r0 to r7 and e0 to e7 can be specified as 16-bit registers. er0 to er7 can be specified as 32-bit registers. 2 . register indirect?@ern the register field of the instruction code specifies an address register (ern), the lower 24 bits of which contain the address of the operand. 3. register indirect with displacement?@(d:16, ern) or @(d:24, ern) a 16-bit or 24-bit displacement contained in the instruction code is added to the contents of an address register (ern) specified by the register field of the instruction, and the lower 24 bits of the sum specify the address of a memory operand. a 16-bit displacement is sign-extended when added.
section 2 cpu rev.3.00 mar. 26, 2007 page 43 of 682 rej09b0353-0300 4. register indirect with post-increment or pre-decrement?@ern+ or @?ern ? register indirect with post-increment?@ern+ the register field of the instruction code specifies an address register (ern) the lower 24 bits of which contain the address of a memory operand. after the operand is accessed, 1, 2, or 4 is added to the address register contents (32 bits) and the sum is stored in the address register. the value added is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the register value should be even. ? register indirect with pre-decrement?@?ern the value 1, 2, or 4 is subtracted from an address register (ern) specified by the register field in the instruction code, and the lower 24 bits of the result become the address of a memory operand. the result is also stored in the address register. the value subtracted is 1 for byte access, 2 for word access, or 4 for longword access. for word or longword access, the resulting register value should be even. 5. absolute address?@aa:8, @aa:16, or @aa:24 the instruction code contains the absolute address of a memory operand. the absolute address may be 8 bits long (@aa:8), 16 bits long (@aa:16), or 24 bits long (@aa:24). for an 8-bit absolute address, the upper 16 bits are all assumed to be 1 (h'ffff). for a 16-bit absolute address the upper 8 bits are a sign extension. a 24-bit absolute address can access the entire address space. table 2.12 indicates the accessible address ranges. table 2.12 absolute address access ranges absolute address 1-mbyte modes 16-mbyte modes 8 bits (@aa:8) h'fff00 to h'fffff (1,048,320 to 1,048,575) h'ffff00 to h'ffffff (16,776,960 to 16,777,215) 16 bits (@aa:16) h'00000 to h'07fff, h'f8000 to h'fffff (0 to 32,767, 1,015,808 to 1,048,575) h'000000 to h'007fff, h'ff8000 to h'ffffff (0 to 32,767, 16,744,448 to 16,777,215) 24 bits (@aa:24) h'00000 to h'fffff (0 to 1,048,575) h'000000 to h'ffffff (0 to 16,777,215)
section 2 cpu rev.3.00 mar. 26, 2007 page 44 of 682 rej09b0353-0300 6. immediate?#xx:8, #xx:16, or #xx:32 the instruction code contains 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) immediate data as an operand. the instruction codes of the adds, subs, inc, and dec instructions contain immediate data implicitly. the instruction codes of some bit manipulation instructions contain 3-bit immediate data specifying a bit number. the trapa instruction code contains 2-bit immediate data specifying a vector address. 7. program-counter relative?@(d:8, pc) or @(d:16, pc) this mode is used in the bcc and bsr instructions. an 8-bit or 16-bit displacement contained in the instruction code is sign-extended to 24 bits and added to the 24-bit pc contents to generate a 24-bit branch address. the pc value to which the displacement is added is the address of the first byte of the next instruction, so the possible branching range is ?126 to +128 bytes (?63 to +64 words) or ?32766 to +32768 bytes (?16383 to +16384 words) from the branch instruction. the resulting value should be an even number. 8. memory indirect?@@aa:8 this mode can be used by the jmp and jsr instructions. the instruction code contains an 8-bit absolute address specifying a memory operand. this memory operand contains a branch address. the memory operand is accessed by longword access. the first byte of the memory operand is ignored, generating a 24-bit branch address. see figure 2.10. the upper bits of the 8-bit absolute address are assumed to be 0 (h'0000), so the address range is 0 to 255 (h'000000 to h'0000ff). note that the first part of this range is also the exception vector area. for further details see section 5, interrupt controller. specified by @aa:8 reserved branch address figure 2.10 memory-indirect branch address specification
section 2 cpu rev.3.00 mar. 26, 2007 page 45 of 682 rej09b0353-0300 when a word-size or longword-size memory operand is specified, or when a branch address is specified, if the specified memory address is odd, the least significant bit is regarded as 0. the accessed data or instruction code therefore begins at the preceding address. see section 2.5.2, memory data formats. 2.7.2 effective address calculation table 2.13 explains how an effective address is calculated in each addressing mode. in the 1-mbyte operating modes the upper 4 bits of the calculated address are ignored in order to generate a 20-bit effective address.
section 2 cpu rev.3.00 mar. 26, 2007 page 46 of 682 rej09b0353-0300 table 2.13 effective address calculation addressing mode and instruction format no. effective address calculation effective address register direct (rn) 1 operand is general register contents op rm rn register indirect (@ern) 2 op r general register contents 31 0 23 0 register indirect with displacement @(d:16, ern)/@(d:24, ern) 3 op r general register contents 31 0 23 0 disp sign extension disp register indirect with post-increment or pre-decrement 4 general register contents 31 0 23 0 1, 2, or 4 op r general register contents 31 0 23 0 1, 2, or 4 op r 1 for a byte operand, 2 for a word operand, 4 for a longword operand register indirect with post-increment @ern+ register indirect with pre-decrement @ e ern
section 2 cpu rev.3.00 mar. 26, 2007 page 47 of 682 rej09b0353-0300 addressing mode and instruction format no. effective address calculation effective address absolute address @aa:8 5 op program-counter relative @(d:8, pc) or @(d:16, pc) 7 0 23 0 abs 23 0 87 @aa:16 op abs 23 0 16 15 h'ffff sign extension @aa:24 op 23 0 abs immediate #xx:8, #xx:16, or #xx:32 6 operand is immediate data op disp 23 0 pc contents disp op imm sign extension
section 2 cpu rev.3.00 mar. 26, 2007 page 48 of 682 rej09b0353-0300 addressing mode and instruction format no. effective address calculation effective address memory indirect @@aa:8 8 op 23 0 abs 23 0 87 h'0000 memory contents 31 0 abs legend: r, rm, rn: op: disp: imm: abs: register field operation field displacement immediate data absolute address advanced mode op 23 0 abs 23 0 87 h'0000 15 0 abs 16 15 normal mode h'00 memory contents
section 2 cpu rev.3.00 mar. 26, 2007 page 49 of 682 rej09b0353-0300 2.8 processing states 2.8.1 overview the h8/300h cpu has four processing states: the program execution state, exception-handling state, power-down state, and reset state. the power-down state includes sleep mode, software standby mode, and hardware standby mode. figure 2.11 classifies the processing states. figure 2.13 indicates the state transitions. processing states program execution state reset state power-down state the cpu executes program instructions in sequence a transient state in which the cpu executes a hardware sequence (saving pc and ccr, fetching a vector, etc.) in response to a reset, interrupt, or other exception the cpu and all on-chip supporting modules are initialized and halted the cpu is halted to conserve power sleep mode software standby mode hardware standby mode exception-handling state figure 2.11 processing states 2.8.2 program execution state in this state the cpu executes program instructions in normal sequence.
section 2 cpu rev.3.00 mar. 26, 2007 page 50 of 682 rej09b0353-0300 2.8.3 exception-handling state the exception-handling state is a transient state that occurs when the cpu alters the normal program flow due to a reset, interrupt, or trap instruction. the cpu fetches a starting address from the exception vector table and branches to that address. in interrupt and trap exception handling the cpu references the stack pointer (er7) and saves the program counter and condition code register. types of exception handling and their priority: exception handling is performed for resets, interrupts, and trap instructions. table 2.14 indicates the types of exception handling and their priority. trap instruction exceptions are accepted at all times in the program execution state. table 2.14 exception handling types and priority priority type of exception detection timing start of exception handling high reset synchronized with clock exception handling starts immediately when res changes from low to high interrupt end of instruction execution or end of exception handling * when an interrupt is requested, exception handling starts at the end of the current instruction or current exception-handling sequence low trap instruction when trapa instruction is executed exception handling starts when a trap (trapa) instruction is executed note: * interrupts are not detected at the end of the andc, orc, xorc, and ldc instructions, or immediately after reset exception handling. figure 2.12 classifies the exception sources. for further details about exception sources, vector numbers, and vector addresses, see section 4, exception handling, and section 5, interrupt controller.
section 2 cpu rev.3.00 mar. 26, 2007 page 51 of 682 rej09b0353-0300 exception sources reset interrupt trap instruction external interrupts internal interrupts (from on-chip supporting modules) figure 2.12 classification of exception sources exception-handling state program execution state sleep mode software standby mode power-down state end of exception handling exception interrupt sleep instruction with ssby = 0 sleep instruction with ssby = 1 nmi, irq , irq , or irq interrupt stby = high, res = low res = high 01 2 notes: 1. 2. from any state except hardware standby mode, a transition to the reset state occurs whenever goes low. from any state, a transition to hardware standby mode occurs when goes low. res stby hardware standby mode * 2 reset state * 1 figure 2.13 state transitions 2.8.4 exception-handling sequences reset exception handling: reset exception handling has the highest priority. the reset state is entered when the res signal goes low. reset exception handling starts after that, when res changes from low to high. when reset exception handling starts the cpu fetches a start address from the exception vector table and starts program execution from that address. all interrupts,
section 2 cpu rev.3.00 mar. 26, 2007 page 52 of 682 rej09b0353-0300 including nmi, are disabled during the reset exception-handling sequence and immediately after it ends. interrupt exception handling and trap instruction exception handling: when these exception-handling sequences begin, the cpu references the stack pointer (er7) and pushes the program counter and condition code register on the stack. next, if the ue bit in the system control register (syscr) is set to 1, the cpu sets this set to 1, the cpu sets the i bit in the condition code register to 1. if the ue bit is cleared to 0, the cpu sets both the i bit and the ui bit in the condition code register to 1. then the cpu fetches a start address from the exception vector table and execution branches to that address. figure 2.14 shows the stack after the exception-handling sequence. sp e 4 sp e 3 sp e 2 sp e 1 sp (er7) before exception handling starts sp (er7) sp+1 sp+2 sp+3 sp+4 after exception handling ends stack area ccr pc even address pushed on stack legend: ccr: sp: condition code register stack pointer notes: 1. 2. pc is the address of the first instruction executed after the return from the exception-handling routine. registers must be saved and restored by word access or longword access, starting at an even address. figure 2.14 stack structure after exception handling
section 2 cpu rev.3.00 mar. 26, 2007 page 53 of 682 rej09b0353-0300 2.8.5 reset state when the res input goes low all current processing stops and the cpu enters the reset state. the i bit in the condition code register is set to 1 by a reset. all interrupts are masked in the reset state. reset exception handling starts when the res signal changes from low to high. the reset state can also be entered by a watchdog timer overflow. for details see section 10, watchdog timer. 2.8.6 power-down state in the power-down state the cpu stops operating to conserve power. there are three modes: sleep mode, software standby mode, and hardware standby mode. sleep mode: a transition to sleep mode is made if the sleep instruction is executed while the ssby bit is cleared to 0 in the system control register (syscr). cpu operations stop immediately after execution of the sleep instruction, but the contents of cpu registers are retained. software standby mode: a transition to software standby mode is made if the sleep instruction is executed while the ssby bit is set to 1 in syscr. the cpu and clock halt and all on-chip supporting modules stop operating. the on-chip supporting modules are reset, but as long as a specified voltage is supplied the contents of cpu registers and on-chip ram are retained. the i/o ports also remain in their existing states. hardware standby mode: a transition to hardware standby mode is made when the stby input goes low. as in software standby mode, the cpu and clock halt and the on-chip supporting modules are reset, but as long as a specified voltage is supplied, on-chip ram contents are retained. for further information see section 17, power-down state.
section 2 cpu rev.3.00 mar. 26, 2007 page 54 of 682 rej09b0353-0300 2.9 basic operational timing 2.9.1 overview the h8/300h cpu operates according to the system clock ( 2.9.2 on-chip memory access timing on-chip memory is accessed in two states. the data bus is 16 bits wide, permitting both byte and word access. figure 2.15 shows the on-chip memory access cycle. figure 2.16 indicates the pin states. t state bus cycle internal address bus internal read signal internal data bus (read access) internal write signal internal data bus (write access) figure 2.15 on-chip memory access cycle
section 2 cpu rev.3.00 mar. 26, 2007 page 55 of 682 rej09b0353-0300 t , rd , wr as figure 2.16 pin states during on-chip memory access 2.9.3 on-chip supporting module access timing the on-chip supporting modules are accessed in three states. the data bus is 8 or 16 bits wide, depending on the register being accessed. figure 2.17 shows the on-chip supporting module access timing. figure 2.18 indicates the pin states. internal address bus internal read signal internal data bus internal write signal address internal data bus figure 2.17 access cycle for on-chip supporting modules
section 2 cpu rev.3.00 mar. 26, 2007 page 56 of 682 rej09b0353-0300 address t , rd , wr as figure 2.18 pin states during access to on-chip supporting modules 2.9.4 access to external address space the external address space is divided into eight areas (areas 0 to 7). bus-controller settings determine whether each area accessed in two or three states. for details see section 6, bus controller.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 57 of 682 rej09b0353-0300 section 3 mcu operating modes 3.1 overview 3.1.1 operating mode selection the h8/3039 group has five operating modes (modes 1, 3, 5 to7) that are selected by the mode pins (md 2 to md 0 ) as indicated in table 3.1. the input at these pins determines expanded mode or single-chip mode. table 3.1 operating mode selection mode pins description operating mode md 2 md 1 md 0 address space initial bus mode * 1 on-chip rom on-chip ram ? 000 ? ? ? ? mode 1 0 0 1 expanded mode 8 bits disabled enabled * 1 mode 2 0 1 0 ? ? ? ? mode 3 0 1 1 expanded mode 8 bits disabled enabled * 1 mode 4 1 0 0 ? ? ? ? mode 5 1 0 1 expanded mode 8 bits enabled enabled * 1 mode 6 1 1 0 single-chip normal mode ? enabled enabled * 2 mode 7 1 1 1 single-chip advanced mode ? enabled enabled * 2 notes: 1. if the ram enable bit (rame) in the system control register (syscr) is cleared to 0, these addresses become external addresses. 2. in mode 6 and 7, clearing bit rame in syscr to 0 and reading the on-chip ram always return h'ff, and write access is ignored. for details, see section 14.3, operation. for the address space size there are three choices: 64 kbytes, 1 mbyte, or 16 mbytes. modes 1 and 3 are on-chip rom disable expanded modes capable of accessing external memory and peripheral devices. mode 1 supports a maximum address space of 1 mbyte. mode 3 supports a maximum address space of 16 mbytes.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 58 of 682 rej09b0353-0300 mode 5 is externally expanded mode that enables access to external memory and peripheral devices and also enables access to the on-chip rom. mode 5 supports a maximum address space of 1 mbyte. modes 6 and 7 are single-chip modes that operate using the on-chip rom, ram, and registers. all i/o ports are available. mode 6 is a normal mode with 64-kbyte address space. mode 7 is an advanced mode with a maximum address space of 1 mbyte. the h8/3039 group can be used only in modes 1, 3, or 5 to 7. the inputs at the mode pins must select one of these seven modes. the inputs at the mode pins must not be changed during operation. 3.1.2 register configuration the h8/3039 group has a mode control register (mdcr) that indicates the inputs at the mode pins (md 2 to md 0 ), and a system control register (syscr). table 3.2 summarizes these registers. table 3.2 registers address * name abbreviation r/w initial value h'fff1 mode control register mdcr r undetermined h'fff2 system control register syscr r/w h'0b note: * the lower 16 bits of the address are indicated.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 59 of 682 rej09b0353-0300 3.2 mode control register (mdcr) mdcr is an 8-bit read-only register that indicates the current operating mode of the h8/3039 group. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 0 ? 4 ? 0 ? 3 ? 0 ? 0 mds0 ? r 2 mds2 ? r 1 mds1 ? r * ** mode select 2 to 0 bits indicating the current operating mode reserved bits note: determined by pins md to md . 2 0 bits 7 and 6?reserved: these bits cannot be modified and are always read as 1. bits 5 to 3?reserved: these bits cannot be modified and are always read as 0. bits 2 to 0?mode select 2 to 0 (mds 2 to mds 0 ): these bits indicate the logic levels at pins md 2 to md 0 (the current operating mode). mds 2 to mds 0 correspond to md 2 to md 0 . mds 1 and mds 0 are read-only bits. the mode pin (md 2 to md 0 ) levels are latched when mdcr is read.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 60 of 682 rej09b0353-0300 3.3 system control register (syscr) syscr is an 8-bit register that controls the operation of the h8/3039 group. bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ue 1 r/w 0 rame 1 r/w 2 nmieg 0 r/w 1 ? 1 ? software standby enables transition to software standby mode user bit enable selects whether to use ui bit in ccr as a user bit or an interrupt mask bit nmi edge select selects the valid edge of the nmi input reserved bit ram enable enables or disables on-chip ram standby timer select 2 to 0 these bits select the waiting time at recovery from software standby mode bit 7?software standby (ssby): enables transition to software standby mode. (for further information about software standby mode see section 17, power-down state.) when software standby mode is exited by an external interrupt, this bit remains set to 1. to clear this bit, write 0. bit 7 ssby description 0 sleep instruction causes transition to sleep mode (initial value) 1 sleep instruction causes transition to software standby mode bits 6 to 4?standby timer select (sts2 to sts0): these bits select the length of time the cpu and on-chip supporting modules wait for the internal clock oscillator to settle when software standby mode is exited by an external interrupt. set these bits so that the waiting time will be at
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 61 of 682 rej09b0353-0300 least 7 ms at the system clock rate. for further information about waiting time selection, see section 17.4.3, selection of oscillator waiting time after exit from software standby mode. bit 6 sts2 bit 5 sts1 bit 4 sts0 description 0 0 0 waiting time = 8,192 states (initial value) 0 0 1 waiting time = 16,384 states 0 1 0 waiting time = 32,768 states 0 1 1 waiting time = 65,536 states 1 0 0 waiting time = 131,072 states 1 0 1 waiting time = 1,024 states 11 ? illegal setting bit 3?user bit enable (ue): selects whether to use the ui bit in the condition code register as a user bit or an interrupt mask bit. bit 3 ue description 0 ui bit in ccr is used as an interrupt mask bit 1 ui bit in ccr is used as a user bit (initial value) bit 2?nmi edge select (nmieg): selects the valid edge of the nmi input. bit 2 nmieg description 0 an interrupt is requested at the falling edge of nmi (initial value) 1 an interrupt is requested at the rising edge of nmi bit 1?reserved: this bit cannot be modified and is always read as 1. bit 0?ram enable (rame): enables or disables the on-chip ram. the rame bit is initialized by the rising edge of the res signal. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 62 of 682 rej09b0353-0300 3.4 operating mode descriptions 3.4.1 mode 1 ports 1, 2, and 5 function as address pins a 19 to a 0 , permitting access to a maximum 1-mbyte address space. the initial bus mode after a reset is 8 bits, with 8-bit access to all areas. 3.4.2 mode 3 ports 1, 2, and 5 and part of port a function as address pins a 23 to a 0 , permitting access to a maximum 16-mbyte address space. the initial bus mode after a reset is 8 bits, with 8-bit access to all areas. a 23 to a 21 are valid when 0 is written in bits 7 to 5 of the bus release control register (brcr). (in this mode a 20 is always used for address output.) 3.4.3 mode 5 ports 1, 2, and 5 can function as address pins a 19 to a 0 , permitting access to a maximum 1-mbyte address space, but following a reset they are input ports. to use ports 1, 2, and 5 as an address bus, the corresponding bits in their data direction registers (p1ddr, p2ddr, and p5ddr) must be set to 1. the address bus width can be selected freely by setting ddr of ports 1, 2, and 5. the initial bus mode after a reset is 8 bits, with 8-bit access to all areas. 3.4.4 mode 6 this mode operates using the on-chip rom, ram, and registers. all i/o ports are available. mode 6 is a normal mode with 64-kbyte address space. 3.4.5 mode 7 this mode is an advanced mode with a 1-mbyte address space which operates using the on-chip rom, ram, and registers. all i/o ports are available. note: the h8/3039 group cannot be used in mode 2 and 4.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 63 of 682 rej09b0353-0300 3.5 pin functions in each operating mode the pin functions of ports 1 to 3, port 5 and port a vary depending on the operating mode. table 3.3 indicates their functions in each operating mode. table 3.3 pin functions in each mode port mode 1 mode 2 * 1 mode 3 mode 4 * 1 mode 5 mode 6 mode 7 port 1 a 7 to a 0 ? a 7 to a 0 ? p1 7 to p1 0 * 2 p1 7 to p1 0 p1 7 to p1 0 port 2 a 15 to a 8 ? a 15 to a 8 ? p2 7 to p2 0 * 2 p2 7 to p2 0 p2 7 to p2 0 port 3 d 7 to d 0 ? d 7 to d 0 ? d 7 to d 0 p3 7 to p3 0 p3 7 to p3 0 port 5 a 19 to a 16 ? a 19 to a 16 ? p5 3 to p5 0 * 2 p5 3 to p5 0 p5 3 to p5 0 port a pa 7 to pa 4 ? pa 6 to pa 4 * 3 , a 20 ? pa 7 to pa 4 pa 7 to pa 4 pa 7 to pa 4 notes: 1. h8/3039 group cannot be used in these modes. 2. initial state. these pins become address output pins when the corresponding bits in the data direction registers (p1ddr, p2ddr, p5ddr) are set to 1. 3. initial state a 20 is always an address output pin. pa 6 to pa 4 are switched over to a 23 to a 21 output by writing 0 in bits 7 to 5 of adrcr. 3.6 memory map in each operating mode figure 3.1 shows a memory map of the h8/3039. figure 3.2 shows a memory map of the h8/3038. figure 3.3 shows a memory map of the h8/3037. figure 3.4 shows a memory map of the h8/3036. the address space is divided into eight areas. modes 1, 3 and 5 are the 8-bit bus mode. the address locations of the on-chip ram and on-chip registers differ between the 1-mbyte modes (modes 1, 5, and 7) and 16-mbyte mode (mode 3), and 64-kbyte mode (mode 6). the address range specifiable by the cpu in the 8- and 16-bit absolute addressing modes (@aa:8 and @aa:16) also differs.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 64 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 1 (1-mbyte expanded modes with on-chip rom disabled) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'fef0f h'fef10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff note: * external addresses can be accessed by disabling on-chip ram. mode 3 (16-mbyte expanded modes with on-chip rom disabled) h'000000 h'0000ff h'007fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) h'1fffff h'200000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ff8000 h'ffef0f h'ffef10 h'ffff00 h'ffff0f h'ffff10 h'ffff1b h'ffff1c h'ffffff h'3fffff h'400000 h'5fffff h'600000 h'7fffff h'800000 h'9fffff h'a00000 h'bfffff h'c00000 h'dfffff h'e00000 figure 3.1 h8/3039 memory map in each operating mode (1)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 65 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 5 (1-mbyte expanded mode with on-chip rom enabled) mode 7 (single-chip advanced mode) mode 6 (single-chip normal mode) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip rom on-chip ram * external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'fef0f h'fef10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) vector area on-chip rom on-chip ram on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'fef10 h'fff00 h'fff0f h'fff1c h'fffff h'1ffff h'f8000 note: * external addresses can be accessed by disabling on-chip ram. on-chip rom on-chip ram on-chip i/o registers h'0000 h'00ff h'ff1c h'ffff h'f70f h'f710 8-bit memory-indirect branch addresses 8-bit absolute addresses f'ff00 f'ff0f vector area figure 3.1 h8/3039 memory map in each operating mode (2)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 66 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 1 (1-mbyte expanded modes with on-chip rom disabled) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'fef10 h'ff70f h'ff710 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff mode 3 (16-mbyte expanded modes with on-chip rom disabled) h'000000 h'0000ff h'007fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) h'1fffff h'200000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ff8000 h'ffef10 h'fff70f h'fff710 h'ffff00 h'ffff0f h'ffff10 h'ffff1b h'ffff1c h'ffffff h'3fffff h'400000 h'5fffff h'600000 h'7fffff h'800000 h'9fffff h'a00000 h'bfffff h'c00000 h'dfffff h'e00000 notes: 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. figure 3.2 h8/3038 memory map in each operating mode (1)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 67 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff h'08000 h'0ffff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 5 (1-mbyte expanded mode with on-chip rom enabled) mode 7 (single-chip advanced mode) mode 6 (single-chip normal mode) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip rom on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'dffff h'e0000 h'fef10 h'ff70f h'ff710 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff h'00000 h'000ff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) vector area on-chip rom on-chip ram on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ff710 h'fff00 h'fff0f h'fff1c h'fffff h'0ffff h'07fff h'f8000 notes: reserved * 1 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. h'0000 h'00ff h'f70f h'f710 8-bit memory-indirect branch addresses 8-bit absolute addresses h'ff00 h'ff0f on-chip i/o registers vector area h'ffff h'ff1c on-chip rom on-chip ram figure 3.2 h8/3038 memory map in each operating mode (2)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 68 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 1 (1-mbyte expanded modes with on-chip rom disabled) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'fef10 h'ffb0f h'ffb10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff mode 3 (16-mbyte expanded modes with on-chip rom disabled) h'000000 h'0000ff h'007fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) h'1fffff h'200000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ff8000 h'ffef10 h'fffb0f h'fffb10 h'ffff00 h'ffff0f h'ffff10 h'ffff1b h'ffff1c h'ffffff h'3fffff h'400000 h'5fffff h'600000 h'7fffff h'800000 h'9fffff h'a00000 h'bfffff h'c00000 h'dfffff h'e00000 notes: 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. figure 3.3 h8/3037 memory map in each operating mode (1)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 69 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff h'08000 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 5 (1-mbyte expanded mode with on-chip rom enabled) mode 7 (single-chip advanced mode) mode 6 (single-chip normal mode) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip rom on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'dffff h'e0000 h'fef10 h'ffb0f h'ffb10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff h'00000 h'000ff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) vector area on-chip rom on-chip ram on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ffb10 h'fff00 h'fff0f h'fff1c h'fffff h'07fff h'f8000 notes: reserved * 1 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. h'0000 h'00ff h'7fff h'fb10 8-bit memory-indirect branch addresses 8-bit absolute addresses vector area h'ff00 h'ff0f on-chip rom on-chip ram h'ff1c h'ffff on-chip i/o registers figure 3.3 h8/3037 memory map in each operating mode (2)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 70 of 682 rej09b0353-0300 h'00000 h'000ff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 1 (1-mbyte expanded modes with on-chip rom disabled) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'fef10 h'ffd0f h'ffd10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff mode 3 (16-mbyte expanded modes with on-chip rom disabled) h'000000 h'0000ff h'007fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) h'1fffff h'200000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ff8000 h'ffef10 h'fffd0f h'fffd10 h'ffff00 h'ffff0f h'ffff10 h'ffff1b h'ffff1c h'ffffff h'3fffff h'400000 h'5fffff h'600000 h'7fffff h'800000 h'9fffff h'a00000 h'bfffff h'c00000 h'dfffff h'e00000 notes: 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. figure 3.4 h8/3036 memory map in each operating mode (1)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 71 of 682 rej09b0353-0300 h'00000 h'000ff h'03fff h'07fff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) mode 5 (1-mbyte expanded mode with on-chip rom enabled) mode 7 (single-chip advanced mode) mode 6 (single-chip normal mode) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 external address space vector area on-chip rom on-chip ram * 2 reserved * 1 external address space on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'f8000 h'dffff h'e0000 h'fef10 h'ffd0f h'ffd10 h'fff00 h'fff0f h'fff10 h'fff1b h'fff1c h'fffff h'00000 h'000ff 8-bit memory-indirect branch addresses 16-bit absolute addresses (first half) vector area on-chip rom on-chip ram on-chip i/o registers 8-bit absolute addresses 16-bit absolute addresses (second half) h'ffd10 h'fff00 h'fff0f h'fff1c h'fffff h'03fff h'f8000 notes: reserved * 1 1. do not access the reserved area. 2. external addresses can be accessed by disabling on-chip ram. h'0000 h'00ff h'3fff h'fd10 f'ff00 f'ff0f h'ff1c h'ffff 8-bit memory-indirect branch addresses 8-bit absolute addresses vector area on-chip rom on-chip ram on-chip i/o registers figure 3.4 h8/3036 memory map in each operating mode (2)
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 72 of 682 rej09b0353-0300 3.7 restrictions on use of mode 6 in mode 6 (single-chip normal mode), on-chip rom area data is undefined if address h'10000 or above (64 kbytes or above) is accessed, and therefore instruction code fetch and data read operations may not always be performed normally. however, there is no problem with address h'10000 and above if the lower 16-bit address is an on-chip ram (h'f710 to h'ff0f) or internal i/o register (h'ff1c to h'ffff) address. table 3.4 shows the restrictions concerning each addressing mode. table 3.4 access restrictions in mode 6 (single-chip normal mode) conditions addressing mode restricted item address range operation restriction register direct (rn)  no problem  register indirect (@ern) contents of ern h'00010000 or above, with lower 16 bits in range h'0000 to h'f710 read data is undefined. writes are invalid. set upper 16 bits of ern to h'0000; or, write same data as in h'00000 ? h'0ffff to h'10000 ? h'1ffff in on-chip rom. register indirect with displacement (@(d:16,ern), @(d:16,ern)) value of ern contents plus displacement register indirect with post-increment (@ern+) register indirect with pre-decrement (@ern-) value of ern contents incremented (or decremented) by 1, 2, or 4 absolute address (@aa:8)  no problem  absolute address (@aa:16) value of @aa sign-extended to 24 bits h'010000 or above, with lower 16 bits in range h'0000 to h'f710 read data is undefined. writes are invalid. do not specify h'8000 or above as absolute address; or, write same data as in h'00000 ? h'0ffff to h'10000 ? h'1ffff in on-chip rom.
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 73 of 682 rej09b0353-0300 conditions addressing mode restricted item address range operation restriction absolute address (@aa:24) value of @aa h'010000 or above, with lower 16 bits in range h'0000 to h'f710 read data is undefined. writes are invalid. do not access addresses in range shown under conditions; or, write same data as in h'00000 ? h'0ffff to h'10000 ? h'1ffff in on-chip rom. immediate  no problem  program-counter relative (@(d:8,pc), @(d:16,pc)) value of pc plus displacement h'010000 or above, with lower 16 bits in range h'0000 to h'f710 does not operate normally since instruction code is undefined. do not access addresses in range shown under conditions; or, write same data as in h'00000 ? h'0ffff to h'10000 ? h'1ffff in on-chip rom. memory indirect (@@aa:8)  no problem 
section 3 mcu operating modes rev.3.00 mar. 26, 2007 page 74 of 682 rej09b0353-0300
section 4 exception handling rev.3.00 mar. 26, 2007 page 75 of 682 rej09b0353-0300 section 4 exception handling 4.1 overview 4.1.1 exception handling types and priority as table 4.1 indicates, exception handling may be caused by a reset, trap instruction, or interrupt. exception handling is prioritized as shown in table 4.1. if two or more exceptions occur simultaneously, they are accepted and processed in priority order. trap instruction exceptions are accepted at all times in the program execution state. table 4.1 exception types and priority priority exception type start of exception handling high reset starts immediately after a low-to-high transition at the res pin interrupt interrupt requests are handled when execution of the current instruction or handling of the current exception is completed low trap instruction (trapa) started by execution of a trap instruction (trapa) 4.1.2 exception handling operation exceptions originate from various sources. trap instructions and interrupts are handled as follows. 1. the program counter (pc) and condition code register (ccr) are pushed onto the stack. 2. the ccr interrupt mask bit is set to 1. 3. a vector address corresponding to the exception source is generated, and program execution starts from the address indicated in the vector address. for a reset exception, steps 2 and 3 above are carried out.
section 4 exception handling rev.3.00 mar. 26, 2007 page 76 of 682 rej09b0353-0300 4.1.3 exception vector table the exception sources are classified as shown in figure 4.1. different vectors are assigned to different exception sources. table 4.2 lists the exception sources and their vector addresses. exception sources  reset  interrupts  trap instruction external interrupts: internal interrupts: nmi, irq 0 , irq 1 , irq 4 , irq 5 25 interrupts from on-chip supporting modules figure 4.1 exception sources
section 4 exception handling rev.3.00 mar. 26, 2007 page 77 of 682 rej09b0353-0300 table 4.2 exception vector table vector address * 1 exception source vector number normal mode advanced mode reset 0 h'0000 to h'0001 h'0000 to h'0003 reserved for system use 1 h'0002 to h'0003 h'0004 to h'0007 2 h'0004 to h'0005 h'0008 to h'000b 3 h'0006 to h'0007 h'000c to h'000f 4 h'0008 to h'0009 h'0010 to h'0013 5 h'000a to h'000b h'0014 to h'0017 6 h'000c to h'000d h'0018 to h'001b external interrupt (nmi) 7 h'000e to h'000f h'001c to h'001f trap instruction (4 sources) 8 h'0010 to h'0011 h'0020 to h'0023 9 h'0012 to h'0013 h'0024 to h'0027 10 h'0014 to h'0015 h'0028 to h'002b 11 h'0016 to h'0017 h'002c to h'002f external interrupt irq 0 12 h'0018 to h'0019 h'0030 to h'0033 irq 1 13 h'001a to h'001b h'0034 to h'0037 reserved for system use 14 h'001c to h'001d h'0038 to h'003b 15 h'001e to h'001f h'003c to h'003f external interrupt irq 4 16 h'0020 to h'0021 h'0040 to h'0043 irq 5 17 h'0022 to h'0023 h'0044 to h'0047 reserved for system use 18 h'0024 to h'0025 h'0048 to h'004b 19 h'0026 to h'0027 h'004c to h'004f internal interrupts * 2 20 to 60 h'0028 to h'0029 to h'0078 to h'0079 h'0050 to h'0053 to h'00f0 to h'00f3 notes: 1. lower 16 bits of the address. 2. for the internal interrupt vectors, see section 5.3.3, interrupt vector table.
section 4 exception handling rev.3.00 mar. 26, 2007 page 78 of 682 rej09b0353-0300 4.2 reset 4.2.1 overview a reset is the highest-priority exception. when the res pin goes low, all processing halts and the h8/3039 group enters the reset state. a reset initializes the internal state of the cpu and the registers of the on-chip supporting modules. reset exception handling begins when the res pin changes from low to high. the chip can also be reset by overflow of the watchdog timer. for details see section 10, watchdog timer. 4.2.2 reset sequence the h8/3039 group enters the reset state when the res pin goes low. to ensure that the chip is reset, hold the res pin low for at least 20 ms at power-up. to reset the chip during operation, hold the res pin low for at least 10 system clock ( ) cycles. when using the flash memory version, hold at "low" level for a least 1usec. see appendix d.2, pin states at reset, for the states of the pins in the reset state. when the res pin goes high after being held low for the necessary time, the h8/3039 group chip starts reset exception handling as follows. ? the internal state of the cpu and the registers of the on-chip supporting modules are initialized, and the i bit is set to 1 in ccr. ? the contents of the reset vector address (h'0000 to h'0003 in advanced mode) are read, and program execution starts from the address indicated in the vector address. figure 4.2 shows the reset sequence in modes 5 and 7.
section 4 exception handling rev.3.00 mar. 26, 2007 page 79 of 682 rej09b0353-0300 (2) (4) (6) (5) (3) (1) res internal address bus internal read signal internal write signal internal data bus (16-bit width) vector fetch internal processing prefetch of first program instruction (1), (3) (2), (4) (5) (6) address of reset vector: (1) = h'000000, (3) = h'000002 start address (contents of reset vector) start address first instruction of program figure 4.2 reset sequence (modes 5 and 7)
section 4 exception handling rev.3.00 mar. 26, 2007 page 80 of 682 rej09b0353-0300 4.2.3 interrupts after reset if an interrupt is accepted after a reset but before the stack pointer (sp) is initialized, pc and ccr will not be saved correctly, leading to a program crash. to prevent this, all interrupt requests, including nmi, are disabled immediately after a reset. the first instruction of the program is always executed immediately after the reset state ends. this instruction should initialize the stack pointer (example: mov.l #xx:32, sp). 4.3 interrupts interrupt exception handling can be requested by five external sources (nmi, irq 0 , irq 1 , irq 4 , irq 5 ) and 25 internal sources in the on-chip supporting modules. figure 4.3 classifies the interrupt sources and indicates the number of interrupts of each type. the on-chip supporting modules that can request interrupts are the watchdog timer (wdt), 16-bit integrated timer unit (itu), serial communication interface (sci), and a/d converter. each interrupt source has a separate vector address. nmi is the highest-priority interrupt and is always accepted. interrupts are controlled by the interrupt controller. the interrupt controller can assign interrupts other than nmi to two priority levels, and arbitrate between simultaneous interrupts. interrupt priorities are assigned in interrupt priority registers a and b (ipra and iprb) in the interrupt controller. for details on interrupts see section 5, interrupt controller. interrupts external interrupts internal interrupts nmi (1) irq 0 , irq 1 , irq 4 , irq 5 (4) wdt * (1) itu (15) sci (8) a/d converter (1) notes: numbers in parentheses are the number of interrupt sources. * when the watchdog timer is used as an interval timer, it generates an interrupt request at every counter overflow. figure 4.3 interrupt sources and number of interrupts
section 4 exception handling rev.3.00 mar. 26, 2007 page 81 of 682 rej09b0353-0300 4.4 trap instruction trap instruction exception handling starts when a trapa instruction is executed. if the ue bit is set to 1 in the system control register (syscr), the exception handling sequence sets the i bit to 1 in ccr. if the ue bit is 0, the i and ui bits are both set to 1. the trapa instruction fetches a start address from a vector table entry corresponding to a vector number from 0 to 3, which is specified in the instruction code. 4.5 stack status after exception handling figure 4.4 shows the stack after completion of trap instruction exception handling and interrupt exception handling. sp-4 sp-3 sp-2 sp-1 sp (er7) figure 4.4 stack after completion of exception handling (advanced mode)
section 4 exception handling rev.3.00 mar. 26, 2007 page 82 of 682 rej09b0353-0300 4.6 notes on stack usage when accessing word data or longword data, the h8/3039 group regards the lowest address bit as 0. the stack should always be accessed by word access or longword access, and the value of the stack pointer (sp, er7) should always be kept even. use the following instructions to save registers: push.w rn (or mov.w rn, @?sp) push.l ern (or mov.l ern, @?sp) use the following instructions to restore registers: pop.w rn (or mov.w @sp+, rn) pop.l ern (or mov.l @sp+, ern) setting sp to an odd value may lead to a malfunction. figure 4.5 shows an example of what happens when the sp value is odd. trapa instruction executed ccr legend: sp pc r1l pc sp sp mov. b r1l, @-er7 sp set to h'ffeff data saved above sp ccr contents lost condition code register program counter general register r1l stack pointer note: the diagram illustrates modes 1, 3, and 5. h'ffefa h'ffefb h'ffefc h'ffefd h'ffeff ccr: pc: r1l: sp: figure 4.5 operation when sp value is odd
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 83 of 682 rej09b0353-0300 section 5 interrupt controller 5.1 overview 5.1.1 features the interrupt controller has the following features: ? interrupt priority registers (iprs) for setting interrupt priorities interrupts other than nmi can be assigned to two priority levels on a module-by-module basis in interrupt priority registers a and b (ipra and iprb). ? three-level masking by the i and ui bits in the cpu condition code register (ccr) ? independent vector addresses all interrupts are independently vectored; the interrupt service routine does not have to identify the interrupt source. ? five external interrupt pins nmi has the highest priority and is always accepted; either the rising or falling edge can be selected. for each of irq 0 , irq 1 , irq 4 , and irq 5 , sensing of the falling edge or level sensing can be selected independently.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 84 of 682 rej09b0353-0300 5.1.2 block diagram figure 5.1 shows a block diagram of the interrupt controller. iscr ier ipra, iprb . . . ovf tme adi adie . . . . . . . cpu ccr i ui ue syscr i: ier: ipra: iprb: iscr: isr: syscr: ue: ui: nmi input irq input irq input section isr interrupt controller priority decision logic interrupt request vector number interrupt mask bit irq enable register interrupt priority register a interrupt priority register b irq sense control register irq status register system control register user bit enable user bit/interrupt mask bit legend: figure 5.1 interrupt controller block diagram
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 85 of 682 rej09b0353-0300 5.1.3 pin configuration table 5.1 lists the interrupt pins. table 5.1 interrupt pins name abbreviation i/o function nonmaskable interrupt nmi input nonmaskable interrupt, rising edge or falling edge selectable external interrupt request 5, 4, 1, and 0 irq 5 , irq 4 , and irq 1 , irq 0 input maskable interrupts, falling edge or level sensing selectable 5.1.4 register configuration table 5.2 lists the registers of the interrupt controller. table 5.2 interrupt controller registers address * 1 name abbreviation r/w initial value h'fff2 system control register syscr r/w h'0b h'fff4 irq sense control register iscr r/w h'00 h'fff5 irq enable register ier r/w h'00 h'fff6 irq status register isr r/(w) * 2 h'00 h'fff8 interrupt priority register a ipra r/w h'00 h'fff9 interrupt priority register b iprb r/w h'00 notes: 1. lower 16 bits of the address. 2. only 0 can be written, to clear flags.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 86 of 682 rej09b0353-0300 5.2 register descriptions 5.2.1 system control register (syscr) syscr is an 8-bit readable/writable register that controls software standby mode, selects the action of the ui bit in ccr, selects the nmi edge, and enables or disables the on-chip ram. only bits 3 and 2 are described here. for the other bits, see section 3.3, system control register (syscr). syscr is initialized to h'0b by a reset and in hardware standby mode. it is not initialized in software standby mode. bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ue 1 r/w 0 rame 1 r/w 2 nmieg 0 r/w 1 ? 1 ? software standby standby timer select 2 to 0 user bit enable selects whether to use the ui bit in ccr as a user bit or interrupt mask bit nmi edge select selects the nmi input edge reserved bit ram enable
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 87 of 682 rej09b0353-0300 bit 3?user bit enable (ue): selects whether to use the ui bit in ccr as a user bit or an interrupt mask bit. bit 3 ue description 0 ui bit in ccr is used as interrupt mask bit 1 ui bit in ccr is used as user bit (initial value) bit 2?nmi edge select (nmieg): selects the nmi input edge. bit 2 nmieg description 0 interrupt is requested at falling edge of nmi input (initial value) 1 interrupt is requested at rising edge of nmi input
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 88 of 682 rej09b0353-0300 5.2.2 interrupt priority registers a and b (ipra, iprb) ipra and iprb are 8-bit readable/writable registers that control interrupt priority. interrupt priority register a (ipra) ipra is an 8-bit readable/writable register in which interrupt priority levels can be set. bit initial value read/write 7 ipra7 0 r/w 6 ipra6 0 r/w 5 ? 0 r/w 4 ipra4 0 r/w 3 ipra3 0 r/w 0 ipra0 0 r/w 2 ipra2 0 r/w 1 ipra1 0 r/w priority level a7 selects the priority level of irq interrupt requests priority level a2 selects the priority level of itu channel 0 interrupt requests priority level a3 selects the priority level of wdt interrupt requests priority level a1 selects the priority level of itu channel 1 interrupt requests priority level a0 selects the priority level of itu channel 2 interrupt requests selects the priority level of irq 1 interrupt requests priority level a6 reserved bit selects the priority level of irq 4 and irq 5 interrupt requests priority level a4 0
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 89 of 682 rej09b0353-0300 ipra is initialized to h'00 by a reset and in hardware standby mode. bit 7?priority level a7 (ipra7): selects the priority level of irq0 interrupt requests. bit7 ipra7 description 0 irq0 interrupt requests have priority level 0 (low priority) (initial value) 1 irq0 interrupt requests have priority level 1 (high priority) bit 6?priority level a6 (ipra6): selects the priority level of irq1 interrupt requests. bit6 ipra6 description 0 irq1 interrupt requests have priority level 0 (low priority) (initial value) 1 irq1 interrupt requests have priority level 1 (high priority) bit 5?reserved bit: this bit can be written and read, but it does not affect interrupt priority. bit 4?priority level a4 (ipra4): selects the priority level of irq 4 and irq 5 interrupt requests. bit4 ipra4 description 0irq 4 , irq 5 interrupt requests have priority level 0 (low priority) (initial value) 1irq 4 , irq 5 interrupt requests have priority level 1 (high priority) bit 3?priority level a3 (ipra3): selects the priority level of wtd interrupt requests. bit3 ipra3 description 0 wdt interrupt requests have priority level 0 (low priority) (initial value) 1 wdt interrupt requests have priority level 1 (high priority)
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 90 of 682 rej09b0353-0300 bit 2?priority level a2 (ipra2): selects the priority level of itu channel 0 interrupt requests. bit2 ipra2 description 0 itu channel 0 interrupt requests have priority level 0 (low priority) (initial value) 1 itu channel 0 interrupt requests have priority level 1 (high priority) bit 1?priority level a1 (ipra1): selects the priority level of itu channel 1 interrupt requests. bit1 ipra1 description 0 itu channel 1 interrupt requests have priority level 0 (low priority) (initial value) 1 itu channel 1 interrupt requests have priority level 1 (high priority) bit 0?priority level a0 (ipra0): selects the priority level of itu channel 2 interrupt requests. bit0 ipra0 description 0 itu channel 2 interrupt requests have priority level 0 (low priority) (initial value) 1 itu channel 2 interrupt requests have priority level 1 (high priority)
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 91 of 682 rej09b0353-0300 interrupt priority register b (iprb) iprb is an 8-bit readable/writable register in which interrupt priority levels can be set. bit initial value read/write 7 iprb7 0 r/w 6 iprb6 0 r/w 5 ? 0 r/w 4 ? 0 r/w 3 iprb3 0 r/w 0 ? 0 r/w 2 iprb2 0 r/w 1 iprb1 0 r/w priority level b7 selects the priority level of itu channel 3 interrupt requests priority level b3 selects the priority level of sci channel 0 interrupt requests selects the priority level of sci channel 1 interrupt requests priority level b2 priority level b1 selects the priority level of a/d converter interrupt request reserved bit selects the priority level of itu channel 4 interrupt requests priority level b6 reserved bits iprb is initialized to h'00 by a reset and in hardware standby mode.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 92 of 682 rej09b0353-0300 bit 7?priority level b7 (iprb7): selects the priority level of itu channel 3 interrupt requests. bit7 iprb7 description 0 itu channel 3 interrupt requests have priority level 0 (low priority) (initial value) 1 itu channel 3 interrupt requests have priority level 1 (high priority) bit 6?priority level b6 (iprb6): selects the priority level of itu channel 4 interrupt requests. bit6 iprb6 description 0 itu channel 4 interrupt requests have priority level 0 (low priority) (initial value) 1 itu channel 4 interrupt requests have priority level 1 (high priority) bits 5 and 4?reserved: these bits cannot be modified and are always read as 0. bit 3?priority level b3 (iprb3): selects the priority level of sci channel 0 interrupt requests. bit3 iprb3 description 0 sci channel 0 interrupt requests have priority level 0 (low priority) (initial value) 1 sci channel 0 interrupt requests have priority level 1 (high priority) bit 2?priority level b2 (iprb2): selects the priority level of sci channel 1 interrupt requests. bit2 iprb2 description 0 sci channel 1 interrupt requests have priority level 0 (low priority) (initial value) 1 sci channel 1 interrupt requests have priority level 1 (high priority) bit 1?priority level b1 (iprb1): selects the priority level of a/d converter interrupt requests. bit1 iprb1 description 0 a/d converter interrupt requests have priority level 0 (low priority) (initial value) 1 a/d converter interrupt requests have priority level 1 (high priority) bit 0?reserved: this bit cannot be modified and is always read as 0.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 93 of 682 rej09b0353-0300 5.2.3 irq status register (isr) isr is an 8-bit readable/writable register that indicates the status of irq 0 , irq 1 , irq 4 , and irq 5 interrupt requests. bit initial value read/write 7 ? 0 ? these bits indicate irq 5 and irq 4 interrupt request status note: only 0 can be written, to clear flags. * 6 ? 0 ? 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 ? 0 ? 2 ? 0 ? 1 irq1f 0 r/(w) * 0 irq0f 0 r/(w) * irq 5 to irq 4 flags these bits indicates irq 1 and irq 0 interrupt request status irq 1 , irq 0 flags reserved bits reserved bits isr is initialized to h'00 by a reset and in hardware standby mode. bits 7, 6, 3 and 2?reserved: these bits cannot be modified and are always read as 0. bits 5, 4, 1 and 0?irq 5 , irq 4 , irq 1 and irq 0 flags (irq5f, irq4f, irq1f, and irq0f): these bits indicate the status of irq 5 , irq 4 , irq 1 , and irq 0 interrupt requests. bits 5, 4, 1, and 0 irq5f, irq4f, irq1f, and irq0f description 0 [clearing conditions] (initial value) ? 0 is written in irqnf after reading the irqnf flag when irqnf = 1. ? irqnsc = 0, irq n input is high, and interrupt exception handling is carried out. ? irqnsc = 1 and irqn interrupt exception handling is carried out. 1 [setting conditions] ? irqnsc = 0 and irq n input is low. ? irqnsc = 1 and irq n input changes from high to low. note: n = 5, 4, 1 and 0
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 94 of 682 rej09b0353-0300 5.2.4 irq enable register (ier) ier is an 8-bit readable/writable register that enables or disables irq 0 , irq 1 , irq 4 , and irq 5 interrupt requests. bit initial value read/write 7 ? 0 r/w these bits enable or disable irq 5 and irq 4 interrupts 6 ? 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 irq1e 0 r/w 0 irq0e 0 r/w irq 5 to irq 4 enable these bits enable or disable irq 1 and irq 0 interrupts irq 1 to irq 0 enable reserved bits reserved bits ier is initialized to h'00 by a reset and in hardware standby mode. bits 7, 6, 3, and 2?reserved: these bits cannot be modified and are always read as 0. bits 5, 4, 1, and 0?irq 5 , irq 4 , irq 1 , and irq 0 enable (irq5e, irq4e, irq1e, irq0e): these bits enable or disable irq5, irq4, irq1, irq 0 interrupts. bits 5, 4, 1, and 0 irq5e, irq4e, irq1e, and irq0e description 0irq 5 , irq 4 , irq 1 , irq 0 interrupts are disabled (initial value) 1irq 5 , irq 4 , irq 1 , irq 0 interrupts are enabled
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 95 of 682 rej09b0353-0300 5.2.5 irq sense control register (iscr) iscr is an 8-bit readable/writable register that selects level sensing or falling-edge sensing of the inputs at pins irq 5 , irq 4 , irq 1 , and irq 0 ? 0 r/w these bits select level sensing or falling-edge sensing for irq 5 and irq 4 interrupts 6 ? 0 r/w 5 irq5sc 0 r/w 4 irq4sc 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 irq1sc 0 r/w 0 irq0sc 0 r/w irq 5 and irq 4 sense control these bits select level sensing or falling-edge sensing for irq 1 and irq 0 interrupts irq 1 and irq 0 sense control reserved bits reserved bits iscr is initialized to h'00 by a reset and in hardware standby mode. bits 7, 6, 3, and 2?reserved: these bits are readable/writable and do not affect selection of level sensing or falling-edge sensing. bits 5, 4, 1, and 0?irq 5 , irq 4 , irq 1 , , and irq 0 sense control (irq5sc, irq4sc, irq1sc, irq0sc): these bits selects whether interrupts irq 5 , irq 4 , irq 1 , irq 0 are requested by level sensing of pins irq 5 , irq 4 , irq 1 , irq 0 or by falling-edge sensing. bits 5, 4, 1, and 0 irq5sc, irq4sc, irq1sc, irq0sc description 0 interrupts are requested when irq 5 , irq 4 , irq 1 , irq 0 inputs are low (initial value) 1 interrupts are requested by falling-edge input at irq 5 , irq 4 , irq 1 , irq 0
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 96 of 682 rej09b0353-0300 5.3 interrupt sources the interrupt sources include external interrupts (nmi, irq 5 , irq 4 , irq 1 and irq 0 ) and 25 internal interrupts. 5.3.1 external interrupts there are five external interrupts: nmi, and irq 5 , irq 4 , irq 1 , and irq 0 . of these, nmi, irq0, irq1, can be used to exit software standby mode. nmi: nmi is the highest-priority interrupt and is always accepted, regardless of the states of the i and ui bits in ccr. the nmieg bit in syscr selects whether an interrupt is requested by the rising or falling edge of the input at the nmi pin. nmi interrupt exception handling has vector number 7. irq 5 , irq 4 , irq 1 , irq 0 interrupts: these interrupts are requested by input signals at pins irq 5 , irq 4 , irq 1 , irq 0 . the irq 5 , irq 4 , irq 1 , irq 0 interrupts have the following features. ? iscr settings can select whether an interrupt is requested by the low level of the input at pins irq 5 , irq 4 , irq 1 , irq 0 , or by the falling edge. ? ier settings can enable or disable the irq 5 , irq 4 , irq 1 , irq 0 interrupts. interrupt priority levels can be assigned by four bits in ipra (ipra7, ipra6, and ipra4). ? the status of irq 5 , irq 4 , irq 1 , irq 0 interrupt requests is indicated in isr. the isr flags can be cleared to 0 by software. figure 5.2 shows a block diagram of interrupts irq 5 , irq 4 , irq 1 , irq 0 . input edge/level sense circuit irqnsc irqnf s r q irqne irqn interrupt request clear signal irqn note: n = 5, 4, 1 and 0 figure 5.2 block diagram of interrupts irq 5 , irq 4 , irq 1 , and irq 0
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 97 of 682 rej09b0353-0300 figure 5.3 shows the timing of the setting of the interrupt flags (irqnf). irqn irqnf input pin note: n = 5, 4, 1 and 0 figure 5.3 timing of setting of irqnf interrupts irq 5 , irq 4 , irq 1 , irq 0 have vector numbers 17, 16, 13, 12. these interrupts are detected regardless of whether the corresponding pin is set for input or output. when using a pin for external interrupt input, clear its ddr bit to 0 and do not use the pin for sci input or output. 5.3.2 internal interrupts twenty-five internal interrupts are requested from the on-chip supporting modules. ? each on-chip supporting module has status flags for indicating interrupt status, and enable bits for enabling or disabling interrupts. ? interrupt priority levels can be assigned in ipra and iprb. 5.3.3 interrupt vector table table 5.3 lists the interrupt sources, their vector addresses, and their default priority order. in the default priority order, smaller vector numbers have higher priority. the priority of interrupts other than nmi can be changed in ipra and iprb. the priority order after a reset is the default order shown in table 5.3.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 98 of 682 rej09b0353-0300 table 5.3 interrupt sources, vector addresses, and priority vector address * interrupt source origin vector number normal mode advanced mode ipr priority nmi external pins 7 h'000e to h'000f h'001c to h'001f ? high irq 0 12 h'0018 to h'0019 h'0030 to h'0033 ipra7 irq 1 13 h'001a to h'001b h'0034 to h0037 ipra6 reserved ? 14 15 h'001c to h'001d h'001e to h'001f h'0038 to h'003b h'003c to h'003f ? irq 4 external pins 16 h'0020 to h'0021 h'0040 to h'0043 ipra4 irq 5 17 h'0022 to h'0023 h'0044 to h'0047 reserved ? 18 19 h'0024 to h'0025 h'0026 to h'0027 h'0048 to h'004b h'004c to h'004f wovi (interval timer) watchdog timer 20 h'0028 to h'0029 h'0050 to h'0053 ipra3 reserved ? 21 22 23 h'002a to h'002b h'002c to h'002d h'002e to h'002f h'0054 to h'0057 h'0058 to h'005b h'005c to h'005f imia0 (compare match/ input capture a0) imib0 (compare match/ input capture b0) ovi0 (overflow 0) itu channel 0 24 25 26 h'0030 to h'0031 h'0032 to h'0033 h'0034 to h'0035 h'0060 to h'0063 h'0064 to h'0067 h'0068 to h'006b ipra2 reserved ? 27 h'0036 to h'0037 h'006c to h'006f imia1 (compare match/ input capture a1) imib1 (compare match/ input capture b1) ovi1 (overflow 1) itu channel 1 28 29 30 h'0038 to h'0039 h'003a to h'003b h'003c to h'003d h'0070 to h'0073 h'0074 to h'0077 h'0078 to h'007b ipra1 reserved ? 31 h'003e to h'003f h'007c to h'007f imia2 (compare match/ input capture a2) imib2 (compare match/ input capture b2) ovi2 (overflow 2) itu channel 2 32 33 34 h'0040 to h'0041 h'0042 to h'0043 h'0044 to h'0045 h'0080 to h'0083 h'0084 to h'0087 h'0088 to h'008b ipra0 reserved ? 35 h'0046 to h'0047 h'008c to h'008f
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 99 of 682 rej09b0353-0300 vector address * interrupt source origin vector number normal mode advanced mode ipr priority imia3 (compare match/ input capture a3) imib3 (compare match/ input capture b3) ovi3 (overflow 3) itu channel 3 36 37 38 h'0048 to h'0049 h'004a to h'004b h'004c to h'004d h'0090 to h'0093 h'0094 to h'0097 h'0098 to h'009b iprb7 reserved ? 39 h'004e to h'004f h'009c to h'009f imia4 (compare match/ input capture a4) imib4 (compare match/ input capture b4) ovi4 (overflow 4) itu channel 4 40 41 42 h'0050 to h'0051 h'0052 to h'0053 h'0054 to h'0055 h'00a0 to h'00a3 h'00a4 to h'00a7 h'00a8 to h'00ab iprb6 reserved ? 43 44 45 46 47 48 49 50 51 h'0056 to h'0057 h'0058 to h'0059 h'005a to h'005b h'005c to h'005d h'005e to h'005f h'0060 to h'0061 h'0062 to h'0063 h'0064 to h'0065 h'0066 to h'0067 h'00ac to h'00af h'00b0 to h'00b3 h'00b4 to h'00b7 h'00b8 to h'00bb h'00bc to h'00bf h'00c0 to h'00c3 h'00c4 to h'00c7 h'00c8 to h'00cb h'00cc to h'00cf ? eri0 (receive error 0) rxi0 (receive data full 0) txi0 (transmit data empty 0) tei0 (transmit end 0) sci channel 0 52 53 54 55 h'0068 to h'0069 h'006a to h'006b h'006c to h'006d h'006e to h'006f h'00d0 to h'00d3 h'00d4 to h'00d7 h'00d8 to h'00db h'00dc to h'00df iprb3 eri1 (receive error 1) rxi1 (receive data full 1) txi1 (transmit data empty 1) tei1 (transmit end 1) sci channel 1 56 57 58 59 h'0070 to h'0071 h'0072 to h'0073 h'0074 to h'0075 h'0076 to h'0077 h'00e0 to h'00e3 h'00e4 to h'00e7 h'00e8 to h'00eb h'00ec to h'00ef iprb2 adi (a/d end) a/d 60 h'0078 to h'0079 h'00f0 to h'00f3 iprb1 low note: * lower 16 bits of the address.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 100 of 682 rej09b0353-0300 5.4 interrupt operation 5.4.1 interrupt handling process the h8/3039 group handles interrupts differently depending on the setting of the ue bit. when ue = 1, interrupts are controlled by the i bit. when ue = 0, interrupts are controlled by the i and ui bits. table 5.4 indicates how interrupts are handled for all setting combinations of the ue, i, and ui bits. nmi interrupts are always accepted except in the reset and hardware standby states. irq interrupts and interrupts from the on-chip supporting modules have their own enable bits. interrupt requests are ignored when the enable bits are cleared to 0. table 5.4 ue, i, and ui bit settings and interrupt handling syscr ccr ue i ui description 10 ? all interrupts are accepted. interrupts with priority level 1 have higher priority. 1 ? no interrupts are accepted except nmi. 00 ? all interrupts are accepted. interrupts with priority level 1 have higher priority. 1 0 nmi and interrupts with priority level 1 are accepted. 1 no interrupts are accepted except nmi. ue = 1 interrupts irq 0 , irq 1 , irq 4 , and irq 5 and interrupts from the on-chip supporting modules can all be masked by the i bit in the cpu's ccr. interrupts are masked when the i bit is set to 1, and unmasked when the i bit is cleared to 0. interrupts with priority level 1 have higher priority. figure 5.4 is a flowchart showing how interrupts are accepted when ue = 1.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 101 of 682 rej09b0353-0300 program execution state interrupt requested? nmi? no ye s no ye s no priority level 1? no irq 0 ? ye s no irq 1 ? ye s adi? ye s no irq 0 ? ye s no irq 1 ? ye s adi? ye s no i = 0? ye s save pc and ccr i 1 branch to interrupt service routine figure 5.4 process up to interrupt acceptance when ue = 1
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 102 of 682 rej09b0353-0300 ? if an interrupt condition occurs and the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. ? when the interrupt controller receives one or more interrupt requests, it selects the highest- priority request, following the ipr interrupt priority settings, and holds other requests pending. if two or more interrupts with the same ipr setting are requested simultaneously, the interrupt controller follows the priority order shown in table 5.3. ? the interrupt controller checks the i bit. if the i bit is cleared to 0, the selected interrupt request is accepted. if the i bit is set to 1, only nmi is accepted; other interrupt requests are held pending. ? when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. ? in interrupt exception handling, pc and ccr are saved to the stack area. the pc value that is saved indicates the address of the first instruction that will be executed after the return from the interrupt service routine. ? next the i bit is set to 1 in ccr, masking all interrupts except nmi. ? the vector address of the accepted interrupt is generated, and the interrupt service routine starts executing from the address indicated by the contents of the vector address. ue = 0 the i and ui bits in the cpu's ccr and the ipr bits enable three-level masking of irq 0 , irq 1 , irq 4 , and irq 5 interrupts and interrupts from the on-chip supporting modules. ? interrupt requests with priority level 0 are masked when the i bit is set to 1, and are unmasked when the i bit is cleared to 0. ? interrupt requests with priority level 1 are masked when the i and ui bits are both set to 1, and are unmasked when either the i bit or the ui bit is cleared to 0. for example, if the interrupt enable bits of all interrupt requests are set to 1, ipra is set to h'10, and iprb is set to h'00 (giving irq 4 and irq 5 interrupt requests priority over other interrupts), interrupts are masked as follows: a. if i = 0, all interrupts are unmasked (priority order: nmi > irq 4 > irq 5 > irq0 ?). b. if i = 1 and ui = 0, only nmi, irq 4 , and irq 5 are unmasked. c. if i = 1 and ui = 1, all interrupts are masked except nmi. figure 5.5 shows the transitions among the above states.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 103 of 682 rej09b0353-0300 all interrupts are unmasked only nmi, irq , and irq are unmasked exception handling, or i 1, ui 1 figure 5.5 interrupt masking state transitions (example) figure 5.6 is a flowchart showing how interrupts are accepted when ue = 0. ? if an interrupt condition occurs and the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. ? when the interrupt controller receives one or more interrupt requests, it selects the highest- priority request, following the ipr interrupt priority settings, and holds other requests pending. if two or more interrupts with the same ipr setting are requested simultaneously, the interrupt controller follows the priority order shown in table 5.3. ? the interrupt controller checks the i bit. if the i bit is cleared to 0, the selected interrupt request is accepted regardless of its ipr setting, and regardless of the ui bit. if the i bit is set to 1 and the ui bit is cleared to 0, only nmi and interrupts with priority level 1 are accepted; interrupt requests with priority level 0 are held pending. if the i bit and ui bit are both set to 1, only nmi is accepted; all other interrupt requests are held pending. ? when an interrupt request is accepted, interrupt exception handling starts after execution of the current instruction has been completed. ? in interrupt exception handling, pc and ccr are saved to the stack area. the pc value that is saved indicates the address of the first instruction that will be executed after the return from the interrupt service routine. ? the i and ui bits are set to 1 in ccr, masking all interrupts except nmi. ? the vector address of the accepted interrupt is generated, and the interrupt service routine starts executing from the address indicated by the contents of the vector address.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 104 of 682 rej09b0353-0300 program execution state interrupt requested? nmi? no ye s no ye s no priority level 1? no irq 0 ? ye s no irq 1 ? ye s adi? ye s no irq 0 ? ye s no irq 1 ? ye s adi? ye s no i = 0? ye s no i = 0? ye s ui = 0? ye s no save pc and ccr i 1, ui 1 figure 5.6 process up to interrupt acceptance when ue = 0
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 105 of 682 rej09b0353-0300 5.4.2 interrupt sequence figure 5.7 shows the interrupt sequence in mode 5 when the program code and stack are in an on- chip memory area. ? 2 sp ? 4 (6), (8) (9), (11) (10), (12) (13) (14) pc and ccr saved to stack vector address starting address of interrupt service routine (contents of vector address) starting address of interrupt service routine; (13) = (10), (12) first instruction of interrupt service routine (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) figure 5.7 interrupt sequence (mode 5, stack in on-chip memory)
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 106 of 682 rej09b0353-0300 5.4.3 interrupt response time table 5.5 indicates the interrupt response time from the occurrence of an interrupt request until the first instruction of the interrupt service routine is executed. table 5.5 interrupt response time external memory 8-bit bus no. item on-chip memory 2 states 3 states 1 interrupt priority decision 2 * 1 2 * 1 2 * 1 2 maximum number of states 1 to 23 1 to 27 1 to 31 * 4 until end of current instruction 3 saving pc and ccr to stack 4 8 12 * 4 4 vector fetch 4 8 12 * 4 5 instruction prefetch * 2 4812 * 4 6 internal processing * 3 444 total 19 to 41 31 to 57 43 to 73 notes: 1. 1 state for internal interrupts. 2. prefetch after the interrupt is accepted and prefetch of the first instruction in the interrupt service routine. 3. internal processing after the interrupt is accepted and internal processing after prefetch. 4. the number of states increases if wait states are inserted in external memory access.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 107 of 682 rej09b0353-0300 5.5 usage notes 5.5.1 contention between interrupt and interrupt-disabling instruction when an instruction clears an interrupt enable bit to 0 to disable the interrupt, the interrupt is not disabled until after execution of the instruction is completed. if an interrupt occurs while a bclr, mov, or other instruction is being executed to clear its interrupt enable bit to 0, at the instant when execution of the instruction ends the interrupt is still enabled, so its interrupt exception handling is carried out. if a higher-priority interrupt is also requested, however, interrupt exception handling for the higher-priority interrupt is carried out, and the lower-priority interrupt is ignored. this also applies to the clearing of an interrupt flag. figure 5.8 shows an example in which an imiea bit is cleared to 0 in the itu's tier. imia exception handling tier write cycle by cpu figure 5.8 contention between interrupt and interrupt-disabling instruction this type of contention will not occur if the interrupt is masked when the interrupt enable bit or flag is cleared to 0.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 108 of 682 rej09b0353-0300 5.5.2 instructions that inhibit interrupts the ldc, andc, orc, and xorc instructions inhibit interrupts. when an interrupt occurs, after determining the interrupt priority, the interrupt controller requests a cpu interrupt. if the cpu is currently executing one of these interrupt-inhibiting instructions, however, when the instruction is completed the cpu always continues by executing the next instruction. 5.5.3 interrupts during eepmov instruction execution the eepmov.b and eepmov.w instructions differ in their reaction to interrupt requests. when the eepmov.b instruction is executing a transfer, no interrupts are accepted until the transfer is completed, not even nmi. when the eepmov.w instruction is executing a transfer, interrupt requests other than nmi are not accepted until the transfer is completed. if nmi is requested, nmi exception handling starts at a transfer cycle boundary. the pc value saved on the stack is the address of the next instruction. programs should be coded as follows to allow for nmi interrupts during eepmov.w execution: l1: eepmo v.w mov.w r4, r4 bne l1 5.5.4 usage notes the irqnf flag specification calls for the flag to be cleared by writing 0 to it after it has been read while set to 1. however, it is possible for the irqnf flag to be cleared by mistake simply by writing 0 to it, irrespective of whether it has been read while set to 1, with the result that interrupt exception handling is not executed. this will occur when the following conditions are met. 1. setting conditions (1) multiple external interrupts (irqa, irqb) are being used. (2) different clearing methods are being used: clearing by writing 0 for the irqaf flag, and clearing by hardware for the irqbf flag. (3) a bit-manipulation instruction is used on the irq status register for clearing the irqaf flag, or else isr is read as a byte unit, the irqaf flag bit is cleared, and the values read in the other bits are written as a byte unit.
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 109 of 682 rej09b0353-0300 2. generation conditions (1) a read of the isr register is executed to clear the irqaf flag while it is set to 1, then the irqbf flag is cleared by the execution of interrupt exception handling. (2) when the irqaf flag is cleared, there is contention with irqb generation (irqaf flag setting). (irqbf was 0 when isr was read to clear the irqaf flag, but irqbf is set to 1 before isr is written to.) if the above setting conditions (1) to (3) and generation conditions (1) and (2) are all fulfilled, when the isr write in generation condition (2) is performed the irqbf flag will be cleared inadvertently, and interrupt exception handling will not be executed. however, this inadvertent clearing of the irqbf flag will not occur if 0 is written to this flag even once between generation conditions (1) and (2). 1 read 0 written 1 read 1 written 1 read 0 written 1 read 0 written irqb executed generation condition (1) generation condition (2) (inadvertent clearing) irqaf irqbf figure 5.9 irqnf flag when interrupt exception handling is not executed
section 5 interrupt controller rev.3.00 mar. 26, 2007 page 110 of 682 rej09b0353-0300 either of the methods shown below should be used to prevent this problem. method 1: when clearing the irqaf flag, read isr as a byte unit instead of using a bit- manipulation instruction, and write a byte value that clears the irqaf flag to 0 and sets the other bits to 1. example: when a = 0 mov.b @isr, r0l mov.b #hfe, r0l mov.b r0l, @isr method 2: perform dummy processing within the irqb interrupt exception handling routine to clear the irqbf flag. example: when b = 1 irqb mov.b #hfd, r0l mov.b r0l, @isr
section 6 bus controller rev.3.00 mar. 26, 2007 page 111 of 682 rej09b0353-0300 section 6 bus controller 6.1 overview the h8/3039 group has an on-chip bus controller that divides the external address space into eight areas and can assign different bus specifications to each. this enables different types of memory to be connected easily. 6.1.1 features features of the bus controller are listed below. ? independent settings for address areas 0 to 7 ? 128-kbyte areas in 1-mbyte mode. ? 2-mbyte areas in 16-mbyte mode. ? areas can be designated for two-state or three-state access. ? four wait modes ? programmable wait mode, pin auto-wait mode, and pin wait modes 0 and 1 can be selected. ? zero to three wait states can be inserted automatically.
section 6 bus controller rev.3.00 mar. 26, 2007 page 112 of 682 rej09b0353-0300 6.1.2 block diagram figure 6.1 shows a block diagram of the bus controller. bus control circuit astcr wcer internal data bus access state control signal wait request signal internal signals wait-state controller wcr area decoder internal address bus wait legend: astcr: wcer: wcr: access state control register wait state controller enable register wait control register figure 6.1 block diagram of bus controller
section 6 bus controller rev.3.00 mar. 26, 2007 page 113 of 682 rej09b0353-0300 6.1.3 input/output pins table 6.1 summarizes the bus controller's input/output pins. table 6.1 bus controller pins name abbreviation i/o function address strobe as output strobe signal indicating valid address output on the address bus read rd output strobe signal indicating reading from the external address space write wr output strobe signal indicating writing to the external address space, with valid data on the data bus(d7 to d0) wait wait input wait request signal for access to external three- state-access areas 6.1.4 register configuration table 6.2 summarizes the bus controller's registers. table 6.2 bus controller registers address * name abbreviation r/w initial value h'ffed access state control register astcr r/w h'ff h'ffee wait control register wcr r/w h'f3 h'ffef wait state controller enable register wcer r/w h'ff h'fff3 address control register adrcr r/w h'fe note: * lower 16 bits of the address.
section 6 bus controller rev.3.00 mar. 26, 2007 page 114 of 682 rej09b0353-0300 6.2 register descriptions 6.2.1 access state control register (astcr) astcr is an 8-bit readable/writable register that selects whether each area is accessed in two states or three states. bit initial value read/write 7 ast7 1 r/w 6 ast6 1 r/w 5 ast5 1 r/w 4 ast4 1 r/w 3 ast3 1 r/w 0 ast0 1 r/w 2 ast2 1 r/w 1 ast1 1 r/w bits selecting number of states for access to each area astcr is initialized to h'ff by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 0?area 7 to 0 access state control (ast7 to ast0): these bits select whether the corresponding area is accessed in two or three states. bits 7 to 0 ast7 to ast0 description 0 areas 7 to 0 are accessed in two states 1 areas 7 to 0 are accessed in three states (initial value) astcr specifies the number of states in which external areas are accessed. on-chip memory and registers are accessed in a fixed number of states that does not depend on astcr settings. therefore, in the single-chip modes (modes 6 and 7), the set value is meaningless.
section 6 bus controller rev.3.00 mar. 26, 2007 page 115 of 682 rej09b0353-0300 6.2.2 wait control register (wcr) wcr is an 8-bit readable/writable register that selects the wait mode for the wait-state controller (wsc) and specifies the number of wait states. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w wait count 1/0 these bits select the number of wait states inserted reserved bits wait mode select 1/0 these bits select the wait mode wcr is initialized to h'f3 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 4?reserved: these bits cannot be modified and are always read as 1. bits 3 and 2?wait mode select 1 and 0 (wms1/0): these bits select the wait mode. bit3 wms1 bit2 wms0 description 0 0 programmable wait mode (initial value) 1 no wait states inserted by wait-state controller 1 0 pin wait mode 1 1 pin auto-wait mode
section 6 bus controller rev.3.00 mar. 26, 2007 page 116 of 682 rej09b0353-0300 bits 1 and 0?wait count 1 and 0 (wc1/0): these bits select the number of wait states inserted in access to external three-state-access areas. bit1 wc1 bit0 wc0 description 0 0 no wait states inserted by wait-state controller 1 1 state inserted 1 0 2 states inserted 1 3 states inserted (initial value) 6.2.3 wait state controller enable register (wcer) wcer is an 8-bit readable/writable register that enables or disables wait-state control of external three-state-access areas by the wait-state controller. bit initial value read/write 7 wce7 1 r/w 6 wce6 1 r/w 5 wce5 1 r/w 4 wce4 1 r/w 3 wce3 1 r/w 0 wce0 1 r/w 2 wce2 1 r/w 1 wce1 1 r/w wait state controller enable 7 to 0 these bits enable or disable wait-state control wcer is initialized to h'ff by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 0?wait-state controller enable 7 to 0 (wce7 to wce0): these bits enable or disable wait-state control of external three-state-access areas. bits 7 to 0 wce7 to wce0 description 0 wait-state control disabled (pin wait mode 0) 1 wait-state control enabled (initial value) wcer enables or disables wait-state control of external three-state-access areas. therefore, in the single-chip modes (modes 6 and 7), the set value is meaningless.
section 6 bus controller rev.3.00 mar. 26, 2007 page 117 of 682 rej09b0353-0300 6.2.4 address control register (adrcr) adrcr is an 8-bit readable/writable register that enables address output on bus lines a23 to a21. bit initial value read/write initial value read/write 7 a 23 e 1 ? 1 r/w 6 a 22 e 1 ? 1 r/w 5 a 21 e 1 ? 1 r/w 4 ? 1 ? 1 ? 3 ? 1 ? 1 ? 0 ? 0 r/w 0 r/w 2 ? 1 ? 1 ? 1 ? 1 ? 1 ? address 23 to 21 enable these bits enable pa 6 to pa 4 to be used for a 23 to a 21 address output reserved bits modes 1 and 5 to 7 mode 3 adrcr is initialized to h'fe by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7?address 23 enable (a 23 e): enables pa4 to be used as the a 23 address output pin. writing 0 in this bit enables a 23 address output from pa4. in modes other than 3 this bit cannot be modified and pa4 has its ordinary input/output functions bit 7 a 23 e description 0pa 4 is the a 23 address output pin 1pa 4 is the pa 4 /tp 4 /tioca 1 input/output pin (initial value) bit 6?address 22 enable (a 22 e): enables pa 5 to be used as the a 22 address output pin. writing 0 in this bit enables a 22 address output from pa 5 . in modes other than 3 this bit cannot be modified and pa 5 has its ordinary input/output functions. bit 6 a 22 e description 0pa 5 is the a 22 address output pin 1pa 5 is the pa 5 /tp 5 /tiocb 1 input/output pin (initial value)
section 6 bus controller rev.3.00 mar. 26, 2007 page 118 of 682 rej09b0353-0300 bit 5?address 21 enable (a 21 e): enables pa 6 to be used as the a 21 address output pin. writing 0 in this bit enables a 21 address output from pa 6 . in modes other than 3 this bit cannot be modified and pa 6 has its ordinary input/output functions. bit 5 a 21 e description 0pa 6 is the a 21 address output pin 1pa 6 is the pa 6 /tp 6 /tioca 2 input/output pin (initial value) bits 4 to 0?reserved
section 6 bus controller rev.3.00 mar. 26, 2007 page 119 of 682 rej09b0353-0300 6.3 operation 6.3.1 area division the external address space is divided into areas 0 to 7. each area has a size of 128 kbytes in the 1-mbyte mode and 2 mbytes in the 16-mbyte mode. figure 6.2 shows a general view of the memory map. notes: there is no area division in modes 6 and 7. 1. the number of access states to on-chip rom, on-chip ram, and on-chip i/o registers is fixed. 2. this area follows area 7 specifications when the rame bit in syscr is 0. 3. this area follows area 7 specifications. h'00000 area 0 (128 kbytes) area 1 (128 kbytes) area 2 (128 kbytes) area 3 (128 kbytes) area 4 (128 kbytes) area 5 (128 kbytes) area 6 (128 kbytes) area 7 (128 kbytes) on-chip ram * 1 * 2 external address space * 3 on-chip i/o registers * 1 a. h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 h'fffff b. h'000000 area 0 (2 mbytes) area 1 (2 mbytes) area 2 (2 mbytes) area 3 (2 mbytes) area 4 (2 mbytes) area 5 (2 mbytes) area 6 (2 mbytes) area 7 (2 mbytes) on-chip ram * 1 * 2 external address space * 3 on-chip i/o registers * 1 h'1fffff h'200000 h'3fffff h'400000 h'5fffff h'600000 h'7fffff h'800000 h'9fffff h'a00000 h'bfffff h'c00000 h'dfffff h'e00000 h'ffffff h'00000 area 1 (128 kbytes) area 2 (128 kbytes) area 3 (128 kbytes) area 4 (128 kbytes) area 5 (128 kbytes) area 6 (128 kbytes) h'1ffff h'20000 h'3ffff h'40000 h'5ffff h'60000 h'7ffff h'80000 h'9ffff h'a0000 h'bffff h'c0000 h'dffff h'e0000 h'fffff 1-mbyte modes with on-chip rom disabled (mode 1) 16-mbyte modes with on-chip rom disabled (mode 3) c. 1-mbyte mode with on-chip rom enabled (mode 5) area 7 (128 kbytes) on-chip ram * 1 * 2 external address space * 3 on-chip i/o registers * 1 on-chip rom * 1 area 0 (128 kbytes) figure 6.2 access area map (mode 1, 3, and 5)
section 6 bus controller rev.3.00 mar. 26, 2007 page 120 of 682 rej09b0353-0300 the bus specifications for each area can be selected in astcr, wcer, and wcr as shown in table 6.3. table 6.3 bus specifications astcr wcer wcr bus specifications astn wcen wms1 wms0 bus width access states wait mode 0 ?? ? 82 disabled 10 ?? 8 3 pin wait mode 0 1 0 0 8 3 programmable wait mode 1 8 3 disabled 1 0 8 3 pin wait mode 1 1 8 3 pin auto-wait mode note: n = 0 to 7
section 6 bus controller rev.3.00 mar. 26, 2007 page 121 of 682 rej09b0353-0300 6.3.2 bus control signal timing 8-bit, three-state-access areas figure 6.3 shows the timing of bus control signals for an 8-bit, three-state-access area. wait states can be inserted. bus cycle address bus as rd d 7 to d 0 wr d 7 to d 0 read access write access external address valid valid t 1 t 2 t 3 figure 6.3 bus control signal timing for 8-bit, three-state-access area
section 6 bus controller rev.3.00 mar. 26, 2007 page 122 of 682 rej09b0353-0300 8-bit, two-state-access areas figure 6.4 shows the timing of bus control signals for an 8-bit, two-state-access area. wait states cannot be inserted. bus cycle address bus as rd d 7 to d 0 wr d 7 to d 0 read access valid valid write access t 1 t 2 external address figure 6.4 bus control signal timing for 8-bit, two-state-access area
section 6 bus controller rev.3.00 mar. 26, 2007 page 123 of 682 rej09b0353-0300 6.3.3 wait modes four wait modes can be selected for each area as shown in table 6.4. table 6.4 wait mode selection astcr wcer wcr astn bit wcen bit wms1 bit wms0 bit wsc control wait mode 0 ??? disabled no wait states 10 ?? disabled pin wait mode 0 1 0 0 enabled programmable wait mode 1 enabled no wait states 1 0 enabled pin wait mode 1 1 enabled pin auto-wait mode note: n = 0 to 7 the astn and wcen bits can be set independently for each area. bits wms1 and wms0 apply to all areas. all areas for which wsc control is enabled operate in the same wait mode.
section 6 bus controller rev.3.00 mar. 26, 2007 page 124 of 682 rej09b0353-0300 pin wait mode 0 the wait state controller is disabled. wait states can only be inserted by wait pin control. during access to an external three-state-access area, if the wait pin is low at the fall of the system clock ( ) in the t 2 state, a wait state (t w ) is inserted. if the wait pin remains low, wait states continue to be inserted until the wait signal goes high. figure 6.5 shows the timing. address bus data bus as rd wr data bus t 1 t 2 t w t w t 3 inserted by wait signal write data *** read data read access write access external address wait pin note: * arrows indicate time of sampling of the wait pin. figure 6.5 pin wait mode 0
section 6 bus controller rev.3.00 mar. 26, 2007 page 125 of 682 rej09b0353-0300 pin wait mode 1 in all accesses to external three-state-access areas, the number of wait states (t w ) selected by bits wc1 and wc0 are inserted. if the wait pin is low at the fall of the system clock ( ) in the last of these wait states, an additional wait state is inserted. if the wait pin remains low, wait states continue to be inserted until the wait signal goes high. pin wait mode 1 is useful for inserting four or more wait states, or for inserting different numbers of wait states for different external devices. if the wait count is 0, this mode operates in the same way as pin wait mode 0. figure 6.6 shows the timing when the wait count is 1 (wc1 = 0, wc0 = 1) and one additional wait state is inserted by wait input. address bus data bus as rd wr t 1 t 2 t w t w t 3 write data * read data * read access write access note: * arrows indicate time of sampling of the wait pin. wait pin data bus external address write data inserted by wait count inserted by wait signal figure 6.6 pin wait mode 1
section 6 bus controller rev.3.00 mar. 26, 2007 page 126 of 682 rej09b0353-0300 pin auto-wait mode if the wait pin is low, the number of wait states (t w ) selected by bits wc1 and wc0 are inserted. in pin auto-wait mode, if the wait pin is low at the fall of the system clock ( ) in the t 2 state, the number of wait states (t w ) selected by bits wc1 and wc0 are inserted. no additional wait states are inserted even if the wait pin remains low. figure 6.7 shows the timing when the wait count is 1. address bus data bus as rd wr data bus t 1 t 2 t 3 t 1 t 2 t w t 3 * * read data read data write data write data read access write access note: * arrows indicate time of sampling of the wait pin. external address external address wait figure 6.7 pin auto-wait mode
section 6 bus controller rev.3.00 mar. 26, 2007 page 127 of 682 rej09b0353-0300 programmable wait mode the number of wait states (t w ) selected by bits wc1 and wc0 are inserted in all accesses to external three-state-access areas. figure 6.8 shows the timing when the wait count is 1 (wc1 = 0, wc0 = 1). t 1 t 2 t w t 3 address bus as rd wr data bus data bus external address read data write data read access write access figure 6.8 programmable wait mode
section 6 bus controller rev.3.00 mar. 26, 2007 page 128 of 682 rej09b0353-0300 example of wait state control settings a reset initializes astcr and wcer to h'ff and wcr to h'f3, selecting programmable wait mode and three wait states for all areas. software can select other wait modes for individual areas by modifying the astcr, wcer, and wcr settings. figure 6.9 shows an example of wait mode settings. 76543210 0 0 ? 0 0 ? 0 1 ? 0 1 ? 1 0 0 1 0 0 1 1 1 1 1 1 bit: astcr h'0f: wcer h'33: wcr h'f3: area 0 area 1 area 2 area 3 area 4 area 5 area 6 area 7 3-state-access area, programmable wait mode 3-state-access area, programmable wait mode 3-state-access area, pin wait mode 0 3-state-access area, pin wait mode 0 2-state-access area, no wait states inserted 2-state-access area, no wait states inserted 2-state-access area, no wait states inserted 2-state-access area, no wait states inserted note: wait states cannot be inserted in areas designated for two-state access by astcr. figure 6.9 wait mode settings (example)
section 6 bus controller rev.3.00 mar. 26, 2007 page 129 of 682 rej09b0353-0300 6.3.4 interconnections with memory (example) for each area, the bus controller can select two- or three-state access. in three-state-access areas, wait states can be inserted in a variety of modes, simplifying the connection of both high-speed and low-speed devices. figure 6.10 shows a memory map for this example. a 32-kword 8-bit eprom is connected to area 2. this device is accessed in three states via an 8-bit bus. two 32-kword 8-bit sram devices (sram1 and sram2) are connected to area 3. these devices are accessed in two states via an 8-bit bus. one 32-kword 8-bit sram (sram3) is connected to area 7. this device is accessed via an 8-bit bus, using three-state access with an additional wait state inserted in pin auto-wait mode.
section 6 bus controller rev.3.00 mar. 26, 2007 page 130 of 682 rej09b0353-0300 area 2 8-bit, three-state-access area area 0 area 1 area 3 8-bit, two-state-access area areas 4, 5, 6 area 7 8-bit, three-state-access area (one auto-wait state) on-chip rom eprom not used sram1, 2 not used sram3 not used on-chip ram on-chip i/o registers h'00000 h'3ffff h'40000 h'1ffff h'20000 h'47fff h'48000 h'5ffff h'60000 h'6ffff h'70000 h'7ffff h'e0000 h'e7fff h'fffff the bus width and the number of access states of the on-chip memories and i/o registers are fixed; they cannot be changed by register setting. note: figure 6.10 memory map (h8/3039 mode 5)
section 6 bus controller rev.3.00 mar. 26, 2007 page 131 of 682 rej09b0353-0300 6.4 usage notes 6.4.1 register write timing astcr and wcer write timing data written to astcr or wcer takes effect starting from the next bus cycle. figure 6.11 shows the timing when an instruction fetched from area 2 changes area 2 from three-state access to two- state access. address t 1 t 2 t 3 t 1 t 2 t 3 t 1 t 2 astcr address 3-state access to area 2 2-state access to area 2 figure 6.11 astcr write timing 6.4.2 precautions on setting astcr and abwcr * use the h8/3039 group on-chip program to set astcr and abwcr as shown below, so that the on-chip rom access cycle for h8/3039 group can be emulated using the evaluation chip for support tools. modes 5 and 7 astcr0 = 0 abwcr = h'fc note: * the abwcr (bus width control register; lower 16-bit address: h'ffec) is not built onto this lsi. for detailed features of the abwcr, see the h8/3048 group, h8/3048f-ztat tm hardware manual.
section 6 bus controller rev.3.00 mar. 26, 2007 page 132 of 682 rej09b0353-0300
section 7 i/o ports rev.3.00 mar. 26, 2007 page 133 of 682 rej09b0353-0300 section 7 i/o ports 7.1 overview the h8/3039 group has nine input/output ports (ports 1, 2, 3, 5, 6, 8, 9, a, and b) and one input port (port 7). table 7.1 summarizes the port functions. the pins in each port are multiplexed as shown in table 7.1. each port has a data direction register (ddr) for selecting input or output, and a data register (dr) for storing output data. in addition to these registers, ports 2, and 5 have an input pull-up control register (pcr) for switching input pull-up transistors on and off. ports 1 to 3 and ports 5, 6, and 8 can drive one ttl load and a 90-pf capacitive load. ports 9, a, and b can drive one ttl load and a 30-pf capacitive load. ports 1 to 3 and ports 5, 6, 8, 9, a, and b can drive a darlington pair. ports 1, 2, 5, and b can drive leds (with 10-ma current sink). pins p8 1 , p8 0 , pa 7 to pa 0 , and pb 3 to pb 0 have schmitt-trigger input circuits. for block diagrams of the ports see appendix c, i/o block diagrams.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 134 of 682 rej09b0353-0300 table 7.1 port functions port description pins mode 1 mode 3 mode 5 mode 6 mode 7 port 1 ? 8-bit i/o port  can drive leds p1 7 to p1 0 / a 7 to a 0 address output pins (a 7 to a 0 ) address output (a 7 to a 0 ) and generic input ddr = 0: generic input ddr = 1: address output generic input/ output port 2  8-bit i/o port  input pull-up  can drive leds p2 7 to p2 0 / a 15 to a 8 address output pins (a 15 to a 8 ) address output (a 15 to a 8 ) and generic input ddr = 0: generic input ddr = 1: address output generic input/ output port 3  8-bit i/o port p3 7 to p3 0 / d 7 to d 0 data input/output (d 7 to d 0 ) generic input/ output port 5  4-bit i/o port  input pull-up  can drive leds p5 3 to p5 0 / a 19 to a 16 address output (a 19 to a 16 ) address output (a 19 to a 16 ) and 4-bit generic input ddr = 0: generic input ddr = 1: address output generic input/ output port 6  4-bit i/o port p6 5 / wr , p6 4 / rd , p6 3 / as bus control signal output ( wr , rd , as ) p6 0 / wait bus control signal input/output ( wait ) and 1-bit generic input/output generic input/ output port 7  8-bit input port p7 7 to p7 0 / an 7 to an 0 analog input (an 7 to an 0 ) to a/d converter, and generic input port 8 p8 1 / irq 1 irq 1 input and 1-bit generic input/output  2-bit i/o port p8 1 and p8 0 have schmitt inputs p8 0 / irq 0 irq 0 input and 1-bit generic input/output irq 1 and irq 0 input and generic input/ output
section 7 i/o ports rev.3.00 mar. 26, 2007 page 135 of 682 rej09b0353-0300 port description pins mode 1 mode 3 mode 5 mode 6 mode 7 port 9  6-bit i/o port p9 5 /sck 1 / irq 5 , p9 4 /sck 0 / irq 4 , p9 3 /rxd 1 , p9 2 /rxd 0 , p9 1 /txd 1 , p9 0 /txd 0 input and output (sck 1 , sck 0 , rxd 1 , rxd 0 , txd 1 , txd 0 ) for serial communication interfaces 1 and 0 (sci0, 1), irq 5 and irq 4 input, and 6-bit generic input/output port a  8-bit i/o port schmitt inputs pa 7 /tp 7 / tiocb 2 /a 20 output (tp 7 ) from pro- grammable timing pattern controller (tpc), input or output (tiocb 2 ) for 16-bit integrated timer unit (itu), and generic input/output address output (a 20 ) tpc output (tp 7 ), itu input or output (tiocb 2 ), and generic input/output pa 6 /tp 6 / tioca 2 /a 21 , pa 5 /tp 5 / tiocb 1 /a 22 , pa 4 /tp 4 / tioca 1 /a 23 tpc output (tp 6 to tp 4 ), itu input and output (tioca 2 , tiocb 1 , tioca 1 ), and generic input/ output tpc output (tp 6 to tp 4 ), itu input and output (tioca 2 , tiocb 1 , tioca 1 ), address output (a 23 to a 21 ), and generic input/output tpc output (tp 6 to tp 4 ), itu input and output (tioca 2 , tiocb 1 , tioca 1 ), and generic input/output pa 3 /tp 3 / tiocb 0 / tclkd, pa 2 /tp 2 / tioca 0 / tclkc, pa 1 /tp 1 / tclkb, pa 0 /tp 0 / tclka tpc output (tp 3 to tp 0 ), itu input and output (tclkd, tclkc, tclkb, tclka, tiocb 0 , tioca 0 ), and generic input/output
section 7 i/o ports rev.3.00 mar. 26, 2007 page 136 of 682 rej09b0353-0300 port description pins mode 1 mode 3 mode 5 mode 6 mode 7 pb 7 /tp 15 / adtrg tpc output (tp 15 ), trigger input ( adtrg ) to a/d converter, and generic input/output. port b  7-bit i/oport  can drive leds pb 3 to pb 0 have schmitt inputs pb 5 /tp 13 / tocxb 4 , pb 4 /tp 12 / tocxa 4 pb 3 /tp 11 / tiocb 4 , pb 2 /tp 10 / tioca 4 , pb 1 /tp 9 / tiocb 3 , pb 0 /tp 8 / tioca 3 tpc output (tp 13 to tp 8 ), itu input and output (tocxb 4 , tocxa 4 , tiocb 4 , tioca 4 , tiocb 3 , tioca 3 ), and generic input/output
section 7 i/o ports rev.3.00 mar. 26, 2007 page 137 of 682 rej09b0353-0300 7.2 port 1 7.2.1 overview port 1 is an 8-bit input/output port with the pin configuration shown in figure 7.1. the pin functions differ between the expanded modes with on-chip rom disabled, expanded modes with on-chip rom enabled, and single-chip mode. in modes 1, 3 (expanded modes with on-chip rom disabled), they are address bus output pins (a 7 to a 0 ). in mode 5 (expanded modes with on-chip rom enabled), settings in the port 1 data direction register (p1ddr) can designate pins for address bus output (a 7 to a 0 ) or generic input. in modes 6 and 7 (single-chip mode), port 1 is a generic input/output port. pins in port 1 can drive one ttl load and a 90-pf capacitive load. they can also drive a darlington transistor pair. port 1 p1 /a p1 /a p1 /a p1 /a p1 /a p1 /a p1 /a p1 /a 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) 7 6 5 4 3 2 1 0 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 7 6 5 4 3 2 1 0 port 1 pins modes 6 and 7 modes 1 and 3 p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) p1 (input)/a (output) 7 6 5 4 3 2 1 0 mode 5 7 6 5 4 3 2 1 0 figure 7.1 port 1 pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 138 of 682 rej09b0353-0300 7.2.2 register descriptions table 7.2 summarizes the registers of port 1. table 7.2 port 1 registers initial value address * name abbreviation r/w modes 1, 3 modes 5 to 7 h'ffc0 port 1 data direction register p1ddr w h'ff h'00 h'ffc2 port 1 data register p1dr r/w h'00 h'00 note: * lower 16 bits of the address. port 1 data direction register (p1ddr) p1ddr is an 8-bit write-only register that can select input or output for each pin in port 1. bit modes 1, 3 initial value read/write initial value read/write modes 5 to 7 7 p1 ddr 1 ? 0 w 7 6 p1 ddr 1 ? 0 w 6 5 p1 ddr 1 ? 0 w 5 4 p1 ddr 1 ? 0 w 4 3 p1 ddr 1 ? 0 w 3 2 p1 ddr 1 ? 0 w 2 1 p1 ddr 1 ? 0 w 1 0 p1 ddr 1 ? 0 w 0 port 1 data direction 7 to 0 these bits select input or output for port 1 pins p1ddr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p1ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 139 of 682 rej09b0353-0300 port 1 data register (p1dr) p1dr is an 8-bit readable/writable register that stores data for pins p1 7 to p1 0 . bit initial value read/write 7 p1 0 r/w port 1 data 7 to 0 these bits store data for port 1 pins 7 6 p1 0 r/w 6 5 p1 0 r/w 5 4 p1 0 r/w 4 3 p1 0 r/w 3 2 p1 0 r/w 2 1 p1 0 r/w 1 0 p1 0 r/w 0 when a bit in p1ddr is set to 1, if port 1 is read the value of the corresponding p1dr bit is returned directly, regardless of the actual state of the pin. when a bit in p1ddr is cleared to 0, if port 1 is read the corresponding pin level is read. p1dr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 140 of 682 rej09b0353-0300 7.2.3 pin functions in each mode the pin functions of port 1 differ between mode 1, 3 (expanded mode with on-chip rom disabled), mode 5 (expanded mode with on-chip rom enabled), mode 6, and 7 (single-chip mode). the pin functions in each mode are described as follows. modes 1 and 3 address output can be selected for each pin in port 1. figure 7.2 shows the pin functions in modes 1 and 3. port 1 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 7 6 5 4 3 2 1 0 figure 7.2 pin functions in modes 1 and 3 (port 1) mode 5 address output or generic input can be selected for each pin in port 1. a pin becomes an address output pin if the corresponding p1ddr bit is set to 1, and a generic input pin if this bit is cleared to 0. following a reset, all pins are input pins. to use a pin for address output, its p1ddr bit must be set to 1. figure 7.3 shows the pin functions in mode 5.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 141 of 682 rej09b0353-0300 port 1 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 7 6 5 4 3 2 1 0 when p1ddr = 1 p1 (input) p1 (input) p1 (input) p1 (input) p1 (input) p1 (input) p1 (input) p1 (input) 7 6 5 4 3 2 1 0 when p1ddr = 0 figure 7.3 pin functions in mode 5 (port 1) modes 6 and 7 (single-chip mode) input or output can be selected separately for each pin in port 1. a pin becomes an output pin if the corresponding p1ddr bit is set to 1, and an input pin if this bit is cleared to 0. figure 7.4 shows the pin functions in modes 6 and 7. port 1 p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) p1 (input/output) 7 6 5 4 3 2 1 0 figure 7.4 pin functions in modes 6 and 7 (port 1)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 142 of 682 rej09b0353-0300 7.3 port 2 7.3.1 overview port 2 is an 8-bit input/output port with the pin configuration shown in figure 7.5. pin functions differ according to operation mode. in modes 1 and 3 (expanded mode with on-chip rom disabled), port 2 consists of address bus output pins (a 15 to a 8 ). in mode 5 (expanded mode with on-chip rom enabled), settings in the port 2 data direction register (p2ddr) can designate pins for address bus output (a 15 to a 8 ) or generic input. in modes 6 and 7 (single-chip mode), port 2 is a generic input/output port. port 2 has software-programmable built-in pull-up transistors. pins in port 2 can drive one ttl load and a 90-pf capacitive load. they can also drive a darlington transistor pair. port 2 p2 /a p2 /a p2 /a p2 /a p2 /a p2 /a p2 /a p2 /a 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) 7 6 5 4 3 2 1 0 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 15 14 13 12 11 10 9 8 port 2 pins mode 6 and 7 modes 1 and 3 p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) p2 (input)/a (output) 7 6 5 4 3 2 1 0 modes 5 15 14 13 12 11 10 9 8 figure 7.5 port 2 pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 143 of 682 rej09b0353-0300 7.3.2 register descriptions table 7.3 summarizes the registers of port 2. table 7.3 port 2 registers initial value address * name abbreviation r/w modes 1 and 3 modes 5 to 7 h'ffc1 port 2 data direction register p2ddr w h'ff h'00 h'ffc3 port 2 data register p2dr r/w h'00 h'00 h'ffd8 port 2 input pull-up control register p2pcr r/w h'00 h'00 note: * lower 16 bits of the address. port 2 data direction register (p2ddr) p2ddr is an 8-bit write-only register that can select input or output for each pin in port 2. bit modes 1 and 3 initial value read/write initial value read/write modes 5 to 7 7 p2 ddr 1 ? 0 w 7 6 p2 ddr 1 ? 0 w 6 5 p2 ddr 1 ? 0 w 5 4 p2 ddr 1 ? 0 w 4 3 p2 ddr 1 ? 0 w 3 2 p2 ddr 1 ? 0 w 2 1 p2 ddr 1 ? 0 w 1 0 p2 ddr 1 ? 0 w 0 port 2 data direction 7 to 0 these bits select input or output for port 2 pins p2ddr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p2ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 144 of 682 rej09b0353-0300 port 2 data register (p2dr) p2dr is an 8-bit readable/writable register that stores data for pins p2 7 to p2 0 . bit initial value read/write 7 p2 0 r/w port 2 data 7 to 0 these bits store data for port 2 pins 7 6 p2 0 r/w 6 5 p2 0 r/w 5 4 p2 0 r/w 4 3 p2 0 r/w 3 2 p2 0 r/w 2 1 p2 0 r/w 1 0 p2 0 r/w 0 when a bit in p2ddr is set to 1, if port 2 is read the value of the corresponding p2dr bit is returned directly, regardless of the actual state of the pin. when a bit in p2ddr is cleared to 0, if port 2 is read the corresponding pin level is read. p2dr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. port 2 input pull-up control register (p2pcr) p2pcr is an 8-bit readable/writable register that controls the mos input pull-up transistors in port 2. bit initial value read/write 7 p2 pcr 0 r/w port 2 input pull-up control 7 to 0 these bits control input pull-up transistors built into port 2 7 6 p2 pcr 0 r/w 6 5 p2 pcr 0 r/w 5 4 p2 pcr 0 r/w 4 3 p2 pcr 0 r/w 3 2 p2 pcr 0 r/w 2 1 p2 pcr 0 r/w 1 0 p2 pcr 0 r/w 0 when a p2ddr bit is cleared to 0 (selecting generic input) in modes 7 to 5, if the corresponding bit from p2 7 pcr to p2 0 pcr is set to 1, the input pull-up transistor is turned on. p2pcr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 145 of 682 rej09b0353-0300 7.3.3 pin functions in each mode the pin functions of port 2 differ between mode 1, 3 (expanded mode with on-chip rom disabled), mode 5 (expanded mode with on-chip rom enabled), mode 6, and 7 (single-chip mode). the pin functions in each mode are described followings. modes 1 and 3 address output can be selected for each pin in port 2. figure 7.6 shows the pin functions in modes 1 and 3. port 2 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 15 14 13 12 11 10 9 8 figure 7.6 pin functions in modes 1 and 3 (port 2) mode 5 address output or generic input can be selected for each pin in port 2. a pin becomes an address output pin if the corresponding p2ddr bit is set to 1, and a generic input pin if this bit is cleared to 0. following a reset, all pins are input pins. to use a pin for address output, its p2ddr bit must be set to 1. figure 7.7 shows the pin functions in modes 5.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 146 of 682 rej09b0353-0300 port 2 a (output) a (output) a (output) a (output) a (output) a (output) a (output) a (output) 15 14 13 12 11 10 9 8 when p2ddr = 1 p2 (input) p2 (input) p2 (input) p2 (input) p2 (input) p2 (input) p2 (input) p2 (input) 7 6 5 4 3 2 1 0 when p2ddr = 0 figure 7.7 pin functions in modes 1 and 3 (port 2) modes 6 and 7 input or output can be selected separately for each pin in port 2. a pin becomes an output pin if the corresponding p2ddr bit is set to 1, and an input pin if this bit is cleared to 0. figure 7.8 shows the pin functions in modes 6 and 7. port 2 p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) p2 (input/output) 7 6 5 4 3 2 1 0 figure 7.8 pin functions in modes 6 and 7 (port 2)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 147 of 682 rej09b0353-0300 7.3.4 input pull-up transistors port 2 has built-in mos input pull-up transistors that can be controlled by software. these input pull-up transistors can be turned on and off individually. when a p2pcr bit is set to 1 and the corresponding p2ddr bit is cleared to 0, the input pull-up transistor is turned on. the input pull-up transistors are turned off by a reset and in hardware standby mode. in software standby mode they retain their previous state. table 7.4 summarizes the states of the input pull-up transistors in each mode. table 7.4 input pull-up transistor states (port 2) mode reset hardware standby mode software standby mode other modes 1 3 off off off off 5 6 7 off off on/off on/off legend: off: the input pull-up transistor is always off. on/off: the input pull-up transistor is on if p2pcr = 1 and p2ddr = 0. otherwise, it is off.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 148 of 682 rej09b0353-0300 7.4 port 3 7.4.1 overview port 3 is an 8-bit input/output port with the pin configuration shown in figure 7.9. port 3 is a data bus in modes 1, 3 and 5 (expanded modes) and a generic input/output port in mode 6 and 7 (single-chip mode). pins in port 3 can drive one ttl load and a 90-pf capacitive load. they can also drive a darlington transistor pair. port 3 p3 /d p3 /d p3 /d p3 /d p3 /d p3 /d p3 /d p3 /d 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) 7 6 5 4 3 2 1 0 d (input/output) d (input/output) d (input/output) d (input/output) d (input/output) d (input/output) d (input/output) d (input/output) 7 6 5 4 3 2 1 0 port 3 pins modes 6 and 7 modes 1, 3 and 5 figure 7.9 port 3 pin configuration 7.4.2 register descriptions table 7.5 summarizes the registers of port 3. table 7.5 port 3 registers address * name abbreviation r/w initial value h'ffc4 port 3 data direction register p3ddr w h'00 h'ffc6 port 3 data register p3dr r/w h'00 note: * lower 16 bits of the address.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 149 of 682 rej09b0353-0300 port 3 data direction register (p3ddr) p3ddr is an 8-bit write-only register that can select input or output for each pin in port 3. bit initial value read/write 7 p3 ddr 0 w port 3 data direction 7 to 0 these bits select input or output for port 3 pins 7 6 p3 ddr 0 w 6 5 p3 ddr 0 w 5 4 p3 ddr 0 w 4 3 p3 ddr 0 w 3 2 p3 ddr 0 w 2 1 p3 ddr 0 w 1 0 p3 ddr 0 w 0 modes 1, 3, and 5: port 3 functions as a data bus. p3ddr is ignored. modes 6 and 7: port 3 functions as an input/output port. a pin in port 3 becomes an output pin if the corresponding p3ddr bit is set to 1, and an input pin if this bit is cleared to 0. p3ddr is a write-only register. its value cannot be read. all bits return 1 when read. p3ddr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p3ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode. port 3 data register (p3dr) p3dr is an 8-bit readable/writable register that stores data for pins p3 7 to p3 0 . bit initial value read/write 7 p3 0 r/w port 3 data 7 to 0 these bits store data for port 3 pins 7 6 p3 0 r/w 6 5 p3 0 r/w 5 4 p3 0 r/w 4 3 p3 0 r/w 3 2 p3 0 r/w 2 1 p3 0 r/w 1 0 p3 0 r/w 0 when a bit in p3ddr is set to 1, if port 3 is read the value of the corresponding p3dr bit is returned directly, regardless of the actual state of the pin. when a bit in p3ddr is cleared to 0, if port 3 is read the corresponding pin level is read. p3dr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 150 of 682 rej09b0353-0300 7.4.3 pin functions in each mode the pin functions of port 3 differ between modes 1, 3 and 5 and modes 6 and 7. the pin functions in each mode are described below. modes 1, 3 and 5 all pins of port 3 automatically become data input/output pins. figure 7.10 shows the pin functions in modes 1, 3 and 5. port 3 d 7 (input/output) d 6 (input/output) d 5 (input/output) d 4 (input/output) d 3 (input/output) d 2 (input/output) d 1 (input/output) d 0 (input/output) figure 7.10 pin functions in modes 1, 3 and 5 (port 3)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 151 of 682 rej09b0353-0300 modes 6 and 7 input or output can be selected separately for each pin in port 3. a pin becomes an output pin if the corresponding p3ddr bit is set to 1, and an input pin if this bit is cleared to 0. figure 7.11 shows the pin functions in modes 6 and 7. port 3 p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) p3 (input/output) 7 6 5 4 3 2 1 0 figure 7.11 pin functions in modes 6 and 7 (port 3)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 152 of 682 rej09b0353-0300 7.5 port 5 7.5.1 overview port 5 is a 4-bit input/output port with the pin configuration shown in figure 7.12. the pin functions differ depending on the operating mode. in modes 1, 3 (expanded modes with on-chip rom disabled), port 5 consists of address output pins (a19 to a16). in modes 5 (expanded modes with on-chip rom enabled), settings in the port 5 data direction register (p5ddr) designate pins for address bus output (a 19 to a 16 ) or generic input. in mode 6 and 7 (single-chip mode), port 5 is a generic input/output port. port 5 has software-programmable built-in pull-up transistors. port 5 can drive one ttl load and a 90-pf capacitive load. they can also drive an led or a darlington transistor pair. port 5 p5 /a p5 /a p5 /a p5 /a 3 2 1 0 19 18 17 16 a (output) a (output) a (output) a (output) 19 18 17 16 p5 (input)/a (output) p5 (input)/a (output) p5 (input)/a (output) p5 (input)/a (output) 3 2 1 0 port 5 pins modes 1, 3 mode 5 p5 (input/output) p5 (input/output) p5 (input/output) p5 (input/output) 3 2 1 0 modes 6 and 7 19 18 17 16 figure 7.12 port 5 pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 153 of 682 rej09b0353-0300 7.5.2 register descriptions table 7.6 summarizes the registers of port 5. table 7.6 port 5 registers initial value address * name abbreviation r/w modes 1 and 3 modes 5 to 7 h'ffc8 port 5 data direction register p5ddr w h'ff h'f0 h'ffca port 5 data register p5dr r/w h'f0 h'f0 h'ffdb port 5 input pull-up control register p5pcr r/w h'f0 h'f0 note: * lower 16 bits of the address. port 5 data direction register (p5ddr) p5ddr is an 8-bit write-only register that can select input or output for each pin in port 5. bit modes 1 and 3 initial value read/write initial value read/write modes 5 to 7 7 ? 1 ? 1 ? 6 ? 1 ? 1 ? 5 ? 1 ? 1 ? 4 ? 1 ? 1 ? 3 p5 ddr 1 ? 0 w 3 2 p5 ddr 1 ? 0 w 2 1 p5 ddr 1 ? 0 w 1 0 p5 ddr 1 ? 0 w 0 reserved bits port 5 data direction 3 to 0 these bits select input or output for port 5 pins p5ddr is initialized to h'f0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p5ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 154 of 682 rej09b0353-0300 port 5 data register (p5dr) p5dr is an 8-bit readable/writable register that stores data for pins p5 3 to p5 0 . bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 p5 0 r/w 3 2 p5 0 r/w 2 1 p5 0 r/w 1 0 p5 0 r/w 0 reserved bits these bits store data for port 5 pins port 5 data 3 to 0 when a bit in p5ddr is set to 1, if port 5 is read the value of the corresponding p5dr bit is returned directly, regardless of the actual state of the pin. when a bit in p5ddr is cleared to 0, if port 5 is read the corresponding pin level is read. bits p5 7 to p5 4 are reserved. they cannot be modified and are always read as 1. p5dr is initialized to h'f0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. port 5 input pull-up control register (p5pcr) p5pcr is an 8-bit readable/writable register that controls the mos input pull-up transistors in port 5. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 p5 pcr 0 r/w 3 2 p5 pcr 0 r/w 2 1 p5 pcr 0 r/w 1 0 p5 pcr 0 r/w 0 reserved bits these bits control input pull-up transistors built into port 5 port 5 input pull-up control 3 to 0 when a p5ddr bit is cleared to 0 (selecting generic input) in modes 5 to 7, if the corresponding bit from p5 3 pcr to p5 0 pcr is set to 1, the input pull-up transistor is turned on. p5pcr is initialized to h'f0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 155 of 682 rej09b0353-0300 7.5.3 pin functions in each mode the pin functions differ between mode 1, 3 (expanded modes with on-chip rom disabled), mode 5 (expanded modes with on-chip rom enabled), mode 6, and 7 (single-chip mode). the pin functions in each mode are described below. modes 1 and 3 address output can be selected for each pin in port 5. figure 7.13 shows the pin functions in modes 1 and 3. port 5 a (output) a (output) a (output) a (output) 19 18 17 16 figure 7.13 pin functions in modes 1 and 3 (port 5) mode 5 address output or generic input can be selected for each pin in port 5. a pin becomes an address output pin if the corresponding p5ddr bit is set to 1, and a generic input pin if this bit is cleared to 0. following a reset, all pins are input pins. to use a pin for address output, its p5ddr must be set to 1. figure 7.14 shows the pin functions in mode 5. port 5 a (output) a (output) a (output) a (output) 19 18 17 16 when p5ddr = 1 p5 (input) p5 (input) p5 (input) p5 (input) 3 2 1 0 when p5ddr = 0 figure 7.14 pin functions in mode 5 (port 5)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 156 of 682 rej09b0353-0300 modes 6 and 7 input or output can be selected separately for each pin in port 5. a pin becomes an output pin if the corresponding p5ddr bit is set to 1, and an input pin if this bit is cleared to 0. figure 7.15 shows the pin functions in modes 6 and 7. port 5 p5 (input/output) p5 (input/output) p5 (input/output) p5 (input/output) 3 2 1 0 figure 7.15 pin functions in mode 6 and 7 (port 5) 7.5.4 input pull-up transistors port 5 has built-in mos input pull-up transistors that can be controlled by software. these input pull-up transistors can be turned on and off individually. when a p5pcr bit is set to 1 and the corresponding p5ddr bit is cleared to 0, the input pull-up transistor is turned on. the input pull-up transistors are turned off by a reset and in hardware standby mode. in software standby mode they retain their previous state. table 7.7 summarizes the states of the input pull-up transistors in each mode. table 7.7 input pull-up transistor states (port 5) mode reset hardware standby mode software standby mode other modes 1 3 off off off off 5 6 7 off off on/off on/off legend: off: the input pull-up transistor is always off. on/off: the input pull-up transistor is on if p5pcr = 1 and p5ddr = 0. otherwise, it is off.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 157 of 682 rej09b0353-0300 7.6 port 6 7.6.1 overview port 6 is a 4-bit input/output port that is also used for input and output of bus control signals ( wr , rd , as , and wait ). figure 7.16 shows the pin configuration of port 6. in modes 1, 3 and 5, the pin functions are wr , rd , as , and p6 0 / wait . in modes 6 and 7, port 6 is a generic input/output port. pins in port 6 can drive one ttl load and a 90-pf capacitive load. they can also drive a darlington transistor pair. port 6 p6 / p6 / p6 / p6 / 5 4 3 0 wr rd as wait port 6 pins wr rd as p6 0 modes 1, 3 and 5 p6 p6 p6 p6 5 4 3 0 modes 6 and 7 (input/output) (input/output) (input/output) (input/output) (output) (output) (output) (input/output)/ wait (input) figure 7.16 port 6 pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 158 of 682 rej09b0353-0300 7.6.2 register descriptions table 7.8 summarizes the registers of port 6. table 7.8 port 6 registers initial value address * name abbreviation r/w modes 1, 3, and 5 modes 6 and 7 h'ffc9 port 6 data direction register p6ddr w h'f8 h'80 h'ffcb port 6 data register p6dr r/w h'80 h'80 note: * lower 16 bits of the address. port 6 data direction register (p6ddr) p6ddr is an 8-bit write-only register that can select input or output for each pin in port 6. bit initial value read/write 7 ? 1 ? 6 ? 0 w 5 p6 ddr 0 w 5 4 p6 ddr 0 w 4 3 p6 ddr 0 w 3 2 ? 0 w 1 ? 0 w 0 p6 ddr 0 w 0 port 6 data direction 5 to 3, 0 these bits select input or output for port 6 pins reserved bits bits 7, 6, 2, and 1 are reserved. p6ddr is a write-only register. its value cannot be read. all bits return 1 when read. p6ddr is initialized to h'80 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p6ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 159 of 682 rej09b0353-0300 port 6 data register (p6dr) p6dr is an 8-bit readable/writable register that stores data for pins p6 5 to p6 3 and p6 0 . bit initial value read/write 7 ? 1 ? 6 ? 0 r/w 5 p6 0 r/w 5 4 p6 0 r/w 4 3 p6 0 r/w 3 2 ? 0 r/w 1 ? 0 r/w 0 p6 0 r/w 0 reserved bits port 6 data 5 to 3, 0 these bits store data for port 6 pins when a bit in p6ddr is set to 1, if port 6 is read the value of the corresponding p6dr bit is returned directly. when a bit in p6ddr is cleared to 0, if port 6 is read the corresponding pin level is read. bits 7, 6, 2, and 1 are reserved. bit 7 cannot be modified and always reads 1. bits 6, 2, and 1 can be written and read, but cannot be used as ports. if bit 6, 2, or 1 in p6ddr is read while its value is 1, the value of the corresponding bit in p6dr will be read. if bit 6, 2, or 1 in p6ddr is read while its value is 0, it will always read 1. p6dr is initialized to h'80 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 160 of 682 rej09b0353-0300 7.6.3 pin functions in each mode modes 1, 3, and 5 p6 5 to p6 3 function as bus control output pins. p6 0 is either a bus control input pin or generic input/output pin, functioning as an output pin when bit p6 0 ddr is set to 1 and an input pin when this bit is cleared to 0. figure 7.17 and table 7.9 indicate the pin functions in modes 1, 3, and 5. port 6 wr rd as p6 0 (input/output)/ wait (input) (output) (output) (output) figure 7.17 pin functions in modes 1, 3, and 5 (port 6)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 161 of 682 rej09b0353-0300 table 7.9 port 6 pin functions in modes 1, 3, and 5 pin pin functions and selection method p6 5 / wr functions as follows regardless of p6 5 ddr p6 5 ddr 0 1 pin function wr output p6 4 / rd functions as follows regardless of p6 4 ddr p6 4 ddr 0 1 pin function rd output p6 3 / as functions as follows regardless of p6 3 ddr p6 3 ddr 0 1 pin function as output p6 0 / wait bits wce7 to wce0 in wcer, bit wms1 in wcr, and bit p6 0 ddr select the pin function as follows wcer all 1s not all 1s wms1 0 1 ? p6 0 ddr 0 1 0 * 0 * pin function p6 0 input p6 0 output wait input note: * do not set bit p6 0 ddr to 1.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 162 of 682 rej09b0353-0300 modes 6 and 7 input or output can be selected separately for each pin in port 6. a pin becomes an output pin if the corresponding p6ddr bit is set to 1, and an input pin if this bit is cleared to 0. figure 7.18 shows the pin functions in modes 6 and 7. port 6 p6 p6 p6 p6 5 4 3 0 (input/output) (input/output) (input/output) (input/output) figure 7.18 pin functions in modes 6 and 7 (port 6)
section 7 i/o ports rev.3.00 mar. 26, 2007 page 163 of 682 rej09b0353-0300 7.7 port 7 7.7.1 overview port 7 is an 8-bit input port that is also used for analog input to the a/d converter. the pin functions are the same in all operating modes. figure 7.19 shows the pin configuration of port 7. port 7 p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) p7 (input)/an (input) 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 port 7 pins figure 7.19 port 7 pin configuration 7.7.2 register description table 7.10 summarizes the port 7 register. port 7 is an input-only port, so it has no data direction register. table 7.10 port 7 data register address * name abbreviation r/w initial value h'ffce port 7 data register p7dr r undetermined note: * lower 16 bits of the address.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 164 of 682 rej09b0353-0300 port 7 data register (p7dr) bit initial value read/write note: * determined by pins p 7 to p 0 . 0 p7 ? r * 0 1 p7 ? r * 1 2 p7 ? r * 2 3 p7 ? r * 3 4 p7 ? r * 4 5 p7 ? r * 5 6 p7 ? r * 6 7 p7 ? r * 7 when p7dr is read, the pin levels are always read. 7.8 port 8 7.8.1 overview port 8 is a 2-bit input/output port that is also used for irq 1 and irq 0 input. figure 7.20 shows the pin configuration of port 8. pin p8 0 functions as input/output pin or as an irq 0 input pin. pins p8 1 function as either input pins or irq 1 input pins in modes 1, 3, and 5, and as input/output pins or irq 1 input pins in modes 6 and 7. pins in port 8 can drive one ttl load and a 90-pf capacitive load. they can also drive a darlington transistor pair. pins p8 1 and p8 0 have schmitt-trigger inputs. port 8 port 8 pins p8 1 (input)/ irq 1 (input) p8 0 (input/output)/ irq 0 (input) modes 1, 3, and 5 p8 1 / irq 1 p8 0 / irq 0 p8 1 (input/output)/ irq 1 (input) p8 0 (input/output)/ irq 0 (input) modes 6 and 7 figure 7.20 port 8 pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 165 of 682 rej09b0353-0300 7.8.2 register descriptions table 7.11 summarizes the registers of port 8. table 7.11 port 8 registers address * name abbreviation r/w initial value h'ffcd port 8 data direction register p8ddr w h'e0 h'ffcf port 8 data register p8dr r/w h'e0 note: * lower 16 bits of the address. port 8 data direction register (p8ddr) p8ddr is an 8-bit write-only register that can select input or output for each pin in port 8. 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 0 w 3 ? 0 w 2 ? 0 w 1 p8 ddr 0 w 1 0 p8 ddr 0 w 0 reserved bits port 8 data direction 1 and 0 these bits select input or output for port 8 pins bit initial value read/write p8ddr is initialized to h'e0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p8ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 166 of 682 rej09b0353-0300 port 8 data register (p8dr) p8dr is an 8-bit readable/writable register that stores data for pins p8 1 to p8 0 . bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 p8 0 r/w 1 0 p8 0 r/w 0 reserved bits port 8 data 1 and 0 these bits store data for port 8 pins when a bit in p8ddr is set to 1, if port 8 is read the value of the corresponding p8dr bit is returned directly. when a bit in p8ddr is cleared to 0, if port 8 is read the corresponding pin level is read. bits 7 to 2 are reserved. bits 7 to 5 cannot be modified and always read 1. bit 4, 3, and 2 can be written and read, but it cannot be used for port input or output. if bit 4, 3, and 2 of p8ddr is read while its value is 1, bit 4, 3 and 2 of p8dr is read directly. if bit 4, 3, and 2 of p8ddr is read while its value is 0, it always reads 1. p8dr is initialized to h'e0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 167 of 682 rej09b0353-0300 7.8.3 pin functions the port 8 pins are also used for irq 1 and irq 0 . table 7.12 describes the selection of pin functions. table 7.12 port 8 pin functions pin pin functions and selection method p8 1 / irq 1 bit p8 1 ddr selects the pin function as follows p8 1 ddr 0 1 modes 1, 3, and 5 modes 6 and 7 pin function p8 1 input illegal setting p8 1 output irq 1 input p8 0 / irq 0 bit p8 0 ddr selects the pin function as follows p8 0 ddr 0 1 pin function p8 0 input p8 0 output irq 0 input
section 7 i/o ports rev.3.00 mar. 26, 2007 page 168 of 682 rej09b0353-0300 7.9 port 9 7.9.1 overview port 9 is a 6-bit input/output port that is also used for input and output (txd 0 , txd 1 , rxd 0 , rxd 1 , sck 0 , sck 1 ) by serial communication interface channels 0 and 1 (sci0 and sci1), and for irq 5 and irq 4 input. port 9 has the same set of pin functions in all operating modes. figure 7.21 shows the pin configuration of port 9. pins in port 9 can drive one ttl load and a 30-pf capacitive load. they can also drive a darlington transistor pair. port 9 p9 (input/output)/sck p9 (input/output)/sck p9 (input/output)/rxd (input) p9 (input/output)/rxd (input) p9 (input/output)/txd (output) p9 (input/output)/txd (output) 5 4 3 2 1 0 port 9 pins 1 0 (input/output)/ irq (input) (input/output)/ irq (input) 5 4 1 0 1 0 figure 7.21 port 9 pin configuration 7.9.2 register descriptions table 7.13 summarizes the registers of port 9. table 7.13 port 9 registers address * name abbreviation r/w initial value h'ffd0 port 9 data direction register p9ddr w h'c0 h'ffd2 port 9 data register p9dr r/w h'c0 note: * lower 16 bits of the address.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 169 of 682 rej09b0353-0300 port 9 data direction register (p9ddr) p9ddr is an 8-bit write-only register that can select input or output for each pin in port 9. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 p9 ddr 0 w 5 4 p9 ddr 0 w 4 3 p9 ddr 0 w 3 2 p9 ddr 0 w 2 1 p9 ddr 0 w 1 0 p9 ddr 0 w 0 reserved bits port 9 data direction 5 to 0 these bits select input or output for port 9 pins a pin in port 9 becomes an output pin if the corresponding p9ddr bit is set to 1, and an input pin if this bit is cleared to 0. p9ddr is a write-only register. its value cannot be read. all bits return 1 when read. p9ddr is initialized to h'c0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a p9ddr bit is set to 1, the corresponding pin maintains its output state in software standby mode. port 9 data register (p9dr) p9dr is an 8-bit readable/writable register that stores output data for pins p9 5 to p9 0 . bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 p9 0 r/w 4 p9 0 r/w 4 3 p9 0 r/w 3 2 p9 0 r/w 2 1 p9 0 r/w 1 0 p9 0 r/w 0 reserved bits port 9 data 5 to 0 these bits store data for port 9 pins 5 when a bit in p9ddr is set to 1, if port 9 is read the value of the corresponding p9dr bit is returned. when a bit in p9ddr is cleared to 0, if port 9 is read the corresponding pin level is read. bits 7 and 6 are reserved. they cannot be modified and are always read as 1.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 170 of 682 rej09b0353-0300 p9dr is initialized to h'c0 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. 7.9.3 pin functions the port 9 pins are also used for sci input and output (txd, rxd, sck), and for irq 5 and irq 4 input. table 7.14 describes the selection of pin functions. table 7.14 port 9 pin functions pin pin functions and selection method p9 5 /sck 1 / irq 5 bit c/ a in smr of sci1, bits cke0 and cke1 in scr of sci1, and bit p9 5 ddr select the pin function as follows cke1 0 1 c/ a 01 ? cke0 0 1 ?? p9 5 ddr 0 1 ??? pin function p9 5 input p9 5 output sck 1 output sck 1 output sck 1 input irq 5 input p9 4 /sck 0 / irq 4 bit c/ a in smr of sci0, bits cke0 and cke1 in scr of sci, and bit p9 4 ddr select the pin function as follows cke1 0 1 c/ a 01 ? cke0 0 1 ?? p9 4 ddr 0 1 ??? pin function p9 4 input p9 4 output sck 0 output sck 0 output sck 0 input irq 4 input
section 7 i/o ports rev.3.00 mar. 26, 2007 page 171 of 682 rej09b0353-0300 pin pin functions and selection method p9 3 /rxd 1 bit re in scr of sci1 and bit p9 3 ddr select the pin function as follows re 0 1 p9 3 ddr 0 1 ? pin function p9 3 input p9 3 output rxd 1 input p9 2 /rxd 0 bit re in scr of sci 0 , bit smif in scmr, and bit p9 2 ddr select the pin function as follows smif 0 1 re 0 1 ? p9 2 ddr 0 1 ?? pin function p9 2 input p9 2 output rxd 0 input rxd 0 input p9 1 /txd 1 bit te in scr of sci1 and bit p91ddr select the pin function as follows te 0 1 p9 1 ddr 0 1 ? pin function p9 1 input p9 1 output txd 1 output p9 0 /txd 0 bit te in scr of sci0, bit smif in scmr, and bit p9 0 ddr select the pin function as follows smif 0 1 te 0 1 ? p9 0 ddr 0 1 ?? pin function p9 0 input p9 0 output txd 0 output txd 0 output * note: * functions as the txd 0 output pin, but there are two states: one in which the pin is driven, and another in which the pin is at high impedance.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 172 of 682 rej09b0353-0300 7.10 port a 7.10.1 overview port a is an 8-bit input/output port that is also used for output (tp 7 to tp 0 ) from the programmable timing pattern controller (tpc), input and output (tiocb 2 , tioca 2 , tiocb 1 , tioca 1 , tiocb 0 , tioca 0 , tclkd, tclkc, tclkb, tclka) by the 16-bit integrated timer unit (itu), and address output (a 23 to a 20 ). figure 7.22 shows the pin configuration of port a. pins in port a can drive one ttl load and a 30-pf capacitive load. they can also drive a darlington transistor pair. port a has schmitt-trigger inputs. port a pa /tp /tiocb /a pa /tp /tioca /a pa /tp /tiocb /a pa /tp /tioca /a pa /tp /tiocb /tclkd pa /tp /tioca /tclkc pa /tp /tclkb pa /tp /tclka pa (input/output)/tp (output)/tiocb (input/output) pa (input/output)/tp (output)/tioca (input/output) pa (input/output)/tp (output)/tiocb (input/output) pa (input/output)/tp (output)/tioca (input/output) pa (input/output)/tp (output)/tiocb (input/output)/tclkd (input) pa (input/output)/tp (output)/tioca (input/output)/tclkc (input) pa (input/output)/tp (output)/tclkb (input) pa (input/output)/tp (output)/tclka (input) 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 port a pins modes 1, 5 and 7 7 6 5 4 3 2 1 0 20 21 22 23 2 2 1 1 0 0 2 2 1 1 0 0 a (output) pa (input/output)/tp (output)/tioca (input/output) /a (output) pa (input/output)/tp (output)/tiocb (input/output) /a (output) pa (input/output)/tp (output)/tioca (input/output) /a (output) pa (input/output)/tp (output)/tiocb (input/output)/tclkd (input) pa (input/output)/tp (output)/tioca (input/output)/tclkc (input) pa (input/output)/tp (output)/tclkb (input) pa (input/output)/tp (output)/tclka (input) 6 5 4 3 2 1 0 6 5 4 3 2 1 0 mode 3 2 1 1 21 22 23 0 0 20 figure 7.22 port a pin configuration
section 7 i/o ports rev.3.00 mar. 26, 2007 page 173 of 682 rej09b0353-0300 7.10.2 register descriptions table 7.15 summarizes the registers of port a. table 7.15 port a registers initial value address * name abbreviation r/w modes 1, 5, and 7 mode 3 h'ffd1 port a data direction register paddr w h'00 h'80 h'ffd3 port a data register padr r/w h'00 h'00 note: * lower 16 bits of the address. port a data direction register (paddr) paddr is an 8-bit write-only register that can select input or output for each pin in port a. the corresponding paddr bit should also be set when a pin is used as a tpc output. 7 pa ddr 0 w 1 ? port a data direction 7 to 0 these bits select input or output for port a pins 7 6 pa ddr 0 w 0 w 6 5 pa ddr 0 w 0 w 5 4 pa ddr 0 w 0 w 4 3 pa ddr 0 w 0 w 3 2 pa ddr 0 w 0 w 2 1 pa ddr 0 w 0 w 1 0 pa ddr 0 w 0 w 0 bit initial value read/write initial value read/write modes 1, 5, and 7 mode 3 a pin in port a becomes an output pin if the corresponding paddr bit is set to 1, and an input pin if this bit is cleared to 0. however, in mode 3, pa 7 ddr is fixed at 1, and pa7 functions as an address output pin. paddr is a write-only register. its value cannot be read. all bits return 1 when read. paddr is initialized to h'00 in modes 1, 5 and 7 and to h'80 in mode 3 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a paddr bit is set to 1, the corresponding pin maintains its output state in software standby mode.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 174 of 682 rej09b0353-0300 port a data register (padr) padr is an 8-bit readable/writable register that stores data for pins pa 7 to pa 0 . bit initial value read/write 0 pa 0 r/w 0 1 pa 0 r/w 1 2 pa 0 r/w 2 3 pa 0 r/w 3 4 pa 0 r/w 4 5 pa 0 r/w 5 6 pa 0 r/w 6 7 pa 0 r/w 7 port a data 7 to 0 these bits store data for port a pins when a bit in paddr is set to 1, if port a is read the value of the corresponding padr bit is returned directly. when a bit in paddr is cleared to 0, if port a is read the corresponding pin level is read. padr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. when port a pins are used for tpc output, padr stores output data for tpc output groups 0 and 1. if a bit in the next data enable register (ndera) is set to 1, the corresponding padr bit cannot be written. in this case, padr can be updated only when data is transferred from ndra.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 175 of 682 rej09b0353-0300 7.10.3 pin functions the port a pins are also used for tpc output (tp 7 to tp 0 ), itu input/output (tiocb 2 to tiocb 0 , tioca 2 to tioca 0 ) and input (tclkd, tclkc, tclkb, tclka), and as address bus pins (a 23 to a 20 ). table 7.16 describes the selection of pin functions. table 7.16 port a pin functions pin pin functions and selection method pa 7 /tp 7 / tiocb 2 / a 20 the mode setting, itu channel 2 settings (bit pwm2 in tmdr and bits iob2 to iob0 in tior2), bit nder7 in ndera, and bit pa7ddr in paddr select the pin function as follows mode 1, 5 to 7 3 itu channel 2 settings (1) in table below (2) in table below ? pa 7 ddr ? 011 ? nder7 ?? 01 ? pin function tiocb 2 output pa 7 input pa 7 output tp 7 output a 20 output tiocb2 input * note: * tiocb2 input when iob2 = 1 and pwm2 = 0. itu channel 2 settings (2) (1) (2) iob2 0 1 iob1 0 0 1 ? iob0 0 1 ??
section 7 i/o ports rev.3.00 mar. 26, 2007 page 176 of 682 rej09b0353-0300 pin pin functions and selection method pa 6 /tp 6 / tioca 2 / a 21 the mode setting, bit a 21 e in brcr, itu channel 2 settings (bit pwm2 in tmdr and bits ioa2 to ioa0 in tior2), bit nder6 in ndera, and bit pa 6 ddr in paddr select the pin function as follows mode 1, 5 to 7 3 a 21 e ? 10 itu channel 2 settings (1) in table below (2) in table below (1) in table below (2) in table below ? pa 6 ddr ? 011 ? 011 ? nder6 ?? 01 ?? 01 ? pin function tioca 2 output pa 6 input pa 6 output tp 6 output tioca 2 output pa 6 input pa 6 output tp 6 output a 21 output tioca 2 input * tioca 2 input * note: * tioca 2 input when ioa2 = 1. itu channel 2 settings (2) (1) (2) (1) pwm2 0 1 ioa2 0 1 ? ioa1 0 0 1 ?? ioa0 0 1 ?? ?
section 7 i/o ports rev.3.00 mar. 26, 2007 page 177 of 682 rej09b0353-0300 pin pin functions and selection method pa 5 /tp 5 / tiocb 1 / a 22 the mode setting, bit a 22 e in brcr, itu channel 1 settings (bit pwm1 in tmdr and bits iob2 to iob0 in tior1), bit nder5 in ndera, and bit pa 5 ddr in paddr select the pin function as follows mode 1, 5 to 7 3 a 22 e ? 10 itu channel 1 settings (1) in table below (2) in table below (1) in table below (2) in table below ? pa 5 ddr ? 011 ? 011 ? nder5 ?? 01 ?? 01 ? pin function tiocb 1 output pa 5 input pa 5 output tp 5 output tiocb 1 output pa 5 input pa 5 output tp 5 output a 22 output tiocb1 input * tiocb1 input * note: * tiocb 1 input when iob2 = 1 and pwm1 = 0. itu channel 1 settings (2) (1) (2) iob2 0 1 iob1 0 0 1 ? iob0 0 1 ??
section 7 i/o ports rev.3.00 mar. 26, 2007 page 178 of 682 rej09b0353-0300 pin pin functions and selection method pa 4 /tp 4 / tiocb 1 / a 23 the mode setting, bit a 23 e in brcr, itu channel 1 settings (bit pwm1 in tmdr and bits ioa2 to ioa0 in tior1), bit nder4 in ndera, and bit pa 4 ddr in paddr select the pin function as follows mode 1, 5 to 7 3 a 23 e ? 10 itu channel 1 settings (1) in table below (2) in table below (1) in table below (2) in table below ? pa 4 ddr ? 011 ? 011 ? nder4 ?? 01 ?? 01 ? pin function tioca 1 output pa 4 input pa 4 output tp 5 output tioca 1 output pa 4 input pa 4 output tp 4 output a 23 output tioca 1 input * tioca 1 input * note: * tioca 1 input when ioa2 = 1. itu channel 1 settings (2) (1) (2) (1) pwm1 0 1 ioa2 0 1 ? ioa1 001 ?? ioa0 0 1 ?? ?
section 7 i/o ports rev.3.00 mar. 26, 2007 page 179 of 682 rej09b0353-0300 pin pin functions and selection method pa 3 /tp 3 / tiocb 0 / tclkd itu channel 0 settings (bit pwm0 in tmdr and bits iob2 to iob0 in tior0), bits tpsc2 to tpsc0 in tcr4 to tcr0, bit nder3 in ndera, and bit pa3ddr in paddr select the pin function as follows itu channel 0 settings (1) in table below (2) in table below pa 3 ddr ? 011 nder3 ?? 01 tiocb 0 output pa 3 input pa 3 output tp 3 output pin function tiocb 0 input * 1 tclkd input * 2 notes: 1. tiocb0 input when iob2 = 1 and pwm0 = 0. 2. tclkd input when tpsc2 = tpsc1 = tpsc0 = 1 in any of tcr4 to tcr0. itu channel 0 settings (2) (1) (2) iob2 0 1 iob1 0 0 1 ? iob0 0 1 ??
section 7 i/o ports rev.3.00 mar. 26, 2007 page 180 of 682 rej09b0353-0300 pin pin functions and selection method pa 2 /tp 2 / tioca 0 / tclkc itu channel 0 settings (bit pwm0 in tmdr and bits ioa2 to ioa0 in tior0), bits tpsc2 to tpsc0 in tcr4 to tcr0, bit nder2 in ndera, and bit pa 2 ddr in paddr select the pin function as follows itu channel 0 settings (1) in table below (2) in table below pa 2 ddr ? 01 1 nder2 ?? 01 tioca 0 output pa 2 input pa 2 output tp 2 output pin function tioca 0 input * 1 tclkc input * 2 notes: 1. tioca 0 input when ioa2 = 1. 2. tclkc input when tpsc2 = tpsc1 = 1 and tpsc0 = 0 in any of tcr4 to tcr0. itu channel 0 settings (2) (1) (2) (1) pwm0 0 1 ioa2 0 1 ? ioa1 001 ?? ioa0 0 1 ?? ?
section 7 i/o ports rev.3.00 mar. 26, 2007 page 181 of 682 rej09b0353-0300 pin pin functions and selection method pa 1 /tp 1 / tclkb bit nder1 in ndera and bit pa1ddr in paddr select the pin function as follows pa 1 ddr 0 1 1 nder1 ? 01 pa 1 input pa 1 output tp 1 output pin function tclkb input * note: * tclkb input when mdf = 1 in tmdr, or when tpsc2 = 1, tpsc1 = 0, and tpsc0 = 1 in any of tcr4 to tcr0. pa 0 /tp 0 / tclka bit nder0 in ndera and bit pa0ddr in paddr select the pin function as follows pa 0 ddr 0 1 1 nder0 ? 01 pa 0 input pa 0 output tp 0 output pin function tclka input * note: * tclka input when mdf = 1 in tmdr, or when tpsc2 = 1 and tpsc1 = tpsc0 = 0 in any of tcr4 to tcr0.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 182 of 682 rej09b0353-0300 7.11 port b 7.11.1 overview port b is a 7-bit input/output port that is also used for tpc output (tp 15 , tp 13 to tp 8 ), itu input/output (tiocb 4 , tiocb 3 , tioca 4 , tioca 3 ) and itu output (tocxb 4 , tocxa 4 ), and adtrg input to the a/d converter. port b has the same set of pin functions in all operating modes. figure 7.23 shows the pin configuration of port b. pins in port b can drive one ttl load and a 30-pf capacitive load. they can also drive an led or a darlington transistor pair. pins pb 3 to pb 0 have schmitt-trigger inputs. port b pb (input/output)/tp (output)/ adtrg (input) pb (input/output)/tp (output)/tocxb (output) pb (input/output)/tp (output)/tocxa (output) 7 5 4 3 2 1 0 port b pins 15 13 12 11 10 9 8 4 4 pb (input/output)/tp (output)/tiocb (input/output) pb (input/output)/tp (output)/tioca (input/output) pb (input/output)/tp (output)/tiocb (input/output) pb (input/output)/tp (output)/tioca (input/output) 4 4 3 3 figure 7.23 port b pin configuration 7.11.2 register descriptions table 7.17 summarizes the registers of port b. table 7.17 port b registers address * name abbreviation r/w initial value h'ffd4 port b data direction register pbddr w h'00 h'ffd6 port b data register pbdr r/w h'00 note: * lower 16 bits of the address.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 183 of 682 rej09b0353-0300 port b data direction register (pbddr) pbddr is an 8-bit write-only register that can select input or output for each pin in port b. bit initial value read/write 7 pb ddr 0 w 7 6 ? 0 w 5 pb ddr 0 w 5 4 pb ddr 0 w 4 3 pb ddr 0 w 3 2 pb ddr 0 w 2 1 pb ddr 0 w 1 0 pb ddr 0 w 0 port b data 7, 5 to 0 these bits select input or output for port b pins reserved bit a pin in port b becomes an output pin if the corresponding pbddr bit is set to 1, and an input pin if this bit is cleared to 0. bit 6 is reserved. pbddr is a write-only register. its value cannot be read. all bits return 1 when read. pbddr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. if a pbddr bit is set to 1, the corresponding pin maintains its output state in software standby mode. port b data register (pbdr) pbdr is an 8-bit readable/writable register that stores data for pins pb 7 , pb 5 to pb 0 . bit initial value read/write 0 pb 0 r/w 0 1 pb 0 r/w 1 2 pb 0 r/w 2 3 pb 0 r/w 3 4 pb 0 r/w 4 5 pb 0 r/w 5 6 ? 0 r/w 7 pb 0 r/w 7 port b data 7, 5 to 0 these bits store data for port b pins reserved bit when a bit in pbddr is set to 1, if port b is read the value of the corresponding pbdr bit is returned directly. when a bit in pbddr is cleared to 0, if port b is read the corresponding pin level is read. bit 6 is reserved. bit 6 can be written and read, but cannot be used for a port input or output.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 184 of 682 rej09b0353-0300 if bit 6 in pbddr is read while its value is 1, the value of bit 6 in pbdr will be read directly. if bit 6 in pbddr is read while its value is 0, it will always be read as 1. pbdr is initialized to h'00 by a reset and in hardware standby mode. in software standby mode it retains its previous setting. when port b pins are used for tpc output, pbdr stores output data for tpc output groups 2 and 3. if a bit in the next data enable register (nderb) is set to 1, the corresponding pbdr bit cannot be written. in this case, pbdr can be updated only when data is transferred from ndrb. 7.11.3 pin functions the port b pins are also used for tpc output (tp 15 , tp 13 to tp 8 ), itu input/output (tiocb 4 , tiocb 3 , tioca 4 , tioca 3 ) and output (tocxb 4 , tocxa 4 ), and adtrg input. table 7.18 describes the selection of pin functions.
section 7 i/o ports rev.3.00 mar. 26, 2007 page 185 of 682 rej09b0353-0300 table 7.18 port b pin functions pin pin functions and selection method bit trge in adcr, bit nder15 in nderb and bit pb7ddr in pbddr select the pin function as follows pb 7 / tp 15 / adtrg pb 7 ddr 0 1 1 nder15 ? 01 pin function pb 7 input pb 7 output tp 15 output adtrg input * notes: * adtrg input when trge = 1. itu channel 4 settings (bit cmd1 in tfcr and bit exb4 in toer), bit nder13 in nderb, and bit pb 5 ddr in pbddr select the pin function as follows pb 5 / tp 13 / tocxb 4 exb4, cmd1 not both 1 both 1 pb 5 ddr 0 1 1 ? nder13 ? 01 ? pin function pb 5 input pb 5 output tp 13 output tocxb 4 output itu channel 4 settings (bit cmd1 in tfcr and bit exa4 in toer), bit nder12 in nderb, and bit pb4ddr in pbddr select the pin function as follows pb 4 / tp 12 / tocxa 4 exa4, cmd1 not both 1 both 1 pb 4 ddr 0 1 1 ? nder12 ? 01 ? pin function pb 4 input pb 4 output tp 12 output tocxa 4 output
section 7 i/o ports rev.3.00 mar. 26, 2007 page 186 of 682 rej09b0353-0300 pin pin functions and selection method pb 3 / tp 11 / tiocb 4 itu channel 4 settings (bit pwm4 in tmdr, bit cmd1 in tfcr, bit eb4 in toer, and bits iob2 to iob0 in tior4), bit nder11 in nderb, and bit pb 3 ddr in pbddr select the pin function as follows itu channel 4 settings (1) in table below (2) in table below pb 3 ddr ? 01 1 nder11 ?? 01 pin function tiocb 4 output pb 3 input pb 3 output tp 11 output tiocb 4 input * note: * tiocb 4 input when cmd1 = pwm4 = 0 and iob2 = 1. itu channel 4 settings (2) (2) (1) (2) (1) eb4 0 1 cmd1 ? 01 iob2 ? 0001 ? iob1 ? 001 ?? iob0 ? 01 ???
section 7 i/o ports rev.3.00 mar. 26, 2007 page 187 of 682 rej09b0353-0300 pin pin functions and selection method pb 2 / tp 10 / tioca 4 itu channel 4 settings (bit cmd1 in tfcr, bit ea4 in toer, bit pwm4 in tmdr, and bits ioa2 to ioa0 in tior4), bit nder10 in nderb, and bit pb 2 ddr in pbddr select the pin function as follows itu channel 4 settings (1) in table below (2) in table below pb 2 ddr ? 011 nder11 ?? 01 pin function tioca 4 output pb 2 input pb 2 output tp 10 output tioca 4 input * note: * tioca 4 input when cmd1 = pwm4 = 0 and iob2 = 1. itu channel 4 settings (2) (2) (1) (2) (1) ea4 0 1 cmd1 ? 01 pwm4 ? 01 ? ioa2 ? 0001 ?? ioa1 ? 001 ??? ioa0 ? 01 ????
section 7 i/o ports rev.3.00 mar. 26, 2007 page 188 of 682 rej09b0353-0300 pin pin functions and selection method pb 1 /tp 9 / tiocb 3 itu channel 3 settings (bit pwm3 in tmdr, bit cmd1 in tfcr, bit eb3 in toer, and bits iob2 to iob0 in tior3), bit nder11 in nderb, and bit pb 1 ddr in pbddr select the pin function as follows itu channel 3 settings (1) in table below (2) in table below pb 1 ddr ? 011 nder9 ?? 01 pin function tiocb 3 output pb 1 input pb 1 output tp 9 output tiocb 3 input * note: * tiocb3 input when cmd1 = pwm3 = 0 and iob2 = 1. itu channel 3 settings (2) (2) (1) (2) (1) eb3 0 1 cmd1 ? 01 iob2 ? 0001 ? iob1 ? 001 ?? iob0 ? 01 ???
section 7 i/o ports rev.3.00 mar. 26, 2007 page 189 of 682 rej09b0353-0300 pin pin functions and selection method pb 0 /tp 8 / tioca 3 itu channel 3 settings (bit cmd1 in tfcr, bit ea3 in toer, bit pwm3 in tmdr, and bits ioa2 to ioa0 in tior3), bit nder8 in nderb, and bit pb 0 ddr in pbddr select the pin function as follows itu channel 3 settings (1) in table below (2) in table below pb 0 ddr ? 011 nder8 ?? 01 pin function tioca 3 output pb 0 input pb 0 output tp 8 output tioca 3 input * note: * tioca 3 input when cmd1 = pwm3 = 0 and ioa2 = 1. itu channel 3 settings (2) (2) (1) (2) (1) ea3 0 1 cmd1 ? 01 pwm3 ? 01 ? ioa2 ? 0001 ?? ioa1 ? 001 ??? ioa0 ? 01 ????
section 7 i/o ports rev.3.00 mar. 26, 2007 page 190 of 682 rej09b0353-0300
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 191 of 682 rej09b0353-0300 section 8 16-bit integrated timer unit (itu) 8.1 overview the h8/3039 group has a built-in 16-bit integrated timer-pulse unit (itu) with five 16-bit timer channels. 8.1.1 features itu features are listed below. ? capability to process up to 12 pulse outputs or 10 pulse inputs ? ten general registers (grs, two per channel) with independently-assignable output compare or input capture functions ? selection of eight counter clock sources for each channel: internal clocks: , /2, /4, /8 external clocks: tclka, tclkb, tclkc, tclkd ? five operating modes selectable in all channels: ? waveform output by compare match selection of 0 output, 1 output, or toggle output (only 0 or 1 output in channel 2) ? input capture function rising edge, falling edge, or both edges (selectable) ? counter clearing function counters can be cleared by compare match or input capture ? synchronization two or more timer counters (tcnts) can be preset simultaneously, or cleared simultaneously by compare match or input capture. counter synchronization enables synchronous register input and output. ? pwm mode pwm output can be provided with an arbitrary duty cycle. with synchronization, up to five-phase pwm output is possible ? phase counting mode selectable in channel 2 two-phase encoder output can be counted automatically.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 192 of 682 rej09b0353-0300 ? three additional modes selectable in channels 3 and 4 ? reset-synchronized pwm mode if channels 3 and 4 are combined, three-phase pwm output is possible with three pairs of complementary waveforms. ? complementary pwm mode if channels 3 and 4 are combined, three-phase pwm output is possible with three pairs of non-overlapping complementary waveforms. ? buffering input capture registers can be double-buffered. output compare registers can be updated automatically. ? high-speed access via internal 16-bit bus the 16-bit timer counters, general registers, and buffer registers can be accessed at high speed via a 16-bit bus. ? fifteen interrupt sources each channel has two compare match/input capture interrupts and an overflow interrupt. all interrupts can be requested independently. ? output triggering of programmable pattern controller (tpc) compare match/input capture signals from channels 0 to 3 can be used as tpc output triggers. table 8.1 summarizes the itu functions.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 193 of 682 rej09b0353-0300 table 8.1 itu functions item channel 0 channel 1 channel 2 channel 3 channel 4 clock sources internal clocks: , /2, /4, /8 external clocks: tclka, tclkb, tclkc, tclkd, selectable i ndependently general registers (output compare/ input capture registers) gra0, grb0 gra1, grb1 gra2, grb2 gra3, grb3 gra4, grb4 buffer registers ? ? ? bra3, brb3 bra4, brb4 input/output pins tioca 0 , tiocb 0 tioca 1 , tiocb 1 tioca 2 , tiocb 2 tioca 3 , tiocb 3 tioca 4 , tiocb 4 output pins ? ? ? ? tocxa 4 , tocxb 4 counter clearing function gra0/grb0 compare match or input capture gra1/grb1 compare match or input capture gra2/grb2 compare match or input capture gra3/grb3 compare match or input capture gra4/grb4 compare match or input capture 0ooooo 1ooooo compare match output toggle o o ? o o input capture function o o o o o synchronization o o o o o pwm modeooooo reset-synchronized pwm mode ???o o complementary pwm mode ???o o phase counting mode ? ? o ? ? buffering ? ? ? o o interrupt sources three sources  compare match/input capture a0  compare match/input capture b0 overflow three sources  compare match/input capture a1  compare match/input capture b1 overflow three sources  compare match/input capture a2  compare match/input capture b2 overflow three sources  compare match/input capture a3  compare match/input capture b3 overflow three sources  compare match/input capture a4  compare match/input capture b4 overflow legend: o: available ?: not available
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 194 of 682 rej09b0353-0300 8.1.2 block diagrams itu block diagram (overall) figure 8.1 is a block diagram of the itu. 16-bit timer channel 4 16-bit timer channel 3 16-bit timer channel 2 16-bit timer channel 1 16-bit timer channel 0 module data bus bus interface internal data bus imia0 to imia4 imib0 to imib4 ovi0 to ovi4 tclka to tclkd figure 8.1 itu block diagram (overall)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 195 of 682 rej09b0353-0300 block diagram of channels 0 and 1 itu channels 0 and 1 are functionally identical. both have the structure shown in figure 8.2. clock selector comparator control logic tclka to tclkd figure 8.2 block diagram of channels 0 and 1 (for channel 0)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 196 of 682 rej09b0353-0300 block diagram of channel 2 figure 8.3 is a block diagram of channel 2. this is the channel that provides only 0 output and 1 output. clock selector comparator control logic tclka to tclkd figure 8.3 block diagram of channel 2
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 197 of 682 rej09b0353-0300 block diagrams of channels 3 and 4 figure 8.4 is a block diagram of channel 3. figure 8.5 is a block diagram of channel 4. tcnt3 bra3 legend: tcnt3: gra3, grb3: bra3, brb3: tcr3: tior3: tier3: tsr3: timer counter 3 (16 bits) general registers a3 and b3 (input capture/output compare registers) (16 bits 2) buffer registers a3 and b3 (input capture/output compare buffer registers) (16 bits 2) timer control register 3 (8 bits) clock selector comparator control logic gra3 brb3 grb3 tcr3 tior3 tier3 tsr3 tclka to tclkd figure 8.4 block diagram of channel 3
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 198 of 682 rej09b0353-0300 tcnt4 bra4 legend: tcnt4: gra4, grb4: bra4, brb4: tcr4: tior4: tier4: tsr4: timer counter 4 (16 bits) general registers a4 and b4 (input capture/output compare registers) (16 bits 2) buffer registers a4 and b4 (input capture/output compare buffer registers) (16 bits 2) timer control register 4 (8 bits) clock selector comparator control logic gra4 brb4 grb4 tcr4 tior4 tier4 tsr4 module data bus figure 8.5 block diagram of channel 4
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 199 of 682 rej09b0353-0300 8.1.3 input/output pins table 8.2 summarizes the itu pins. table 8.2 itu pins channel name abbre- viation input/ output function common clock input a tclka input external clock a input pin (phase-a input pin in phase counting mode) clock input b tclkb input external clock b input pin (phase-b input pin in phase counting mode) clock input c tclkc input external clock c input pin clock input d tclkd input external clock d input pin 0 input capture/output compare a0 tioca 0 input/ output gra0 output compare or input capture pin pwm output pin in pwm mode input capture/output compare b0 tiocb 0 input/ output grb0 output compare or input capture pin 1 input capture/output compare a1 tioca 1 input/ output gra1 output compare or input capture pin pwm output pin in pwm mode input capture/output compare b1 tiocb 1 input/ output grb1 output compare or input capture pin 2 input capture/output compare a2 tioca 2 input/ output gra2 output compare or input capture pin pwm output pin in pwm mode input capture/output compare b2 tiocb 2 input/ output grb2 output compare or input capture pin 3 input capture/output compare a3 tioca 3 input/ output gra3 output compare or input capture pin pwm output pin in pwm mode, complementary pwm mode, or reset- synchronized pwm mode input capture/output compare b3 tiocb 3 input/ output grb3 output compare or input capture pin pwm output pin in complementary pwm mode or reset-synchronized pwm mode
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 200 of 682 rej09b0353-0300 channel name abbre- viation input/ output function 4 input capture/output compare a4 tioca 4 input/ output gra4 output compare or input capture pin pwm output pin in pwm mode, complementary pwm mode, or reset- synchronized pwm mode input capture/output compare b4 tiocb 4 input/ output grb4 output compare or input capture pin pwm output pin in complementary pwm mode or reset-synchronized pwm mode output compare xa4 tocxa 4 output pwm output pin in complementary pwm mode or reset-synchronized pwm mode output compare xb4 tocxb 4 output pwm output pin in complementary pwm mode or reset-synchronized pwm mode
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 201 of 682 rej09b0353-0300 8.1.4 register configuration table 8.3 summarizes the itu registers. table 8.3 itu registers channel address * 1 name abbre- viation r/w initial value common h'ff60 timer start register tstr r/w h'e0 h'ff61 timer synchro register tsnc r/w h'e0 h'ff62 timer mode register tmdr r/w h'80 h'ff63 timer function control register tfcr r/w h'c0 h'ff90 timer output master enable register toer r/w h'ff h'ff91 timer output control register tocr r/w h'ff 0 h'ff64 timer control register 0 tcr0 r/w h'80 h'ff65 timer i/o control register 0 tior0 r/w h'88 h'ff66 timer interrupt enable register 0 tier0 r/w h'f8 h'ff67 timer status register 0 tsr0 r/(w) * 2 h'f8 h'ff68 timer counter 0 (high) tcnt0h r/w h'00 h'ff69 timer counter 0 (low) tcnt0l r/w h'00 h'ff6a general register a0 (high) gra0h r/w h'ff h'ff6b general register a0 (low) gra0l r/w h'ff h'ff6c general register b0 (high) grb0h r/w h'ff h'ff6d general register b0 (low) grb0l r/w h'ff 1 h'ff6e timer control register 1 tcr1 r/w h'80 h'ff6f timer i/o control register 1 tior1 r/w h'88 h'ff70 timer interrupt enable register 1 tier1 r/w h'f8 h'ff71 timer status register 1 tsr1 r/(w) * 2 h'f8 h'ff72 timer counter 1 (high) tcnt1h r/w h'00 h'ff73 timer counter 1 (low) tcnt1l r/w h'00 h'ff74 general register a1 (high) gra1h r/w h'ff h'ff75 general register a1 (low) gra1l r/w h'ff h'ff76 general register b1 (high) grb1h r/w h'ff h'ff77 general register b1 (low) grb1l r/w h'ff
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 202 of 682 rej09b0353-0300 channel address * 1 name abbre- viation r/w initial value 2 h'ff78 timer control register 2 tcr2 r/w h'80 h'ff79 timer i/o control register 2 tior2 r/w h'88 h'ff7a timer interrupt enable register 2 tier2 r/w h'f8 h'ff7b timer status register 2 tsr2 r/(w) * 2 h'f8 h'ff7c timer counter 2 (high) tcnt2h r/w h'00 h'ff7d timer counter 2 (low) tcnt2l r/w h'00 h'ff7e general register a2 (high) gra2h r/w h'ff h'ff7f general register a2 (low) gra2l r/w h'ff h'ff80 general register b2 (high) grb2h r/w h'ff h'ff81 general register b2 (low) grb2l r/w h'ff 3 h'ff82 timer control register 3 tcr3 r/w h'80 h'ff83 timer i/o control register 3 tior3 r/w h'88 h'ff84 timer interrupt enable register 3 tier3 r/w h'f8 h'ff85 timer status register 3 tsr3 r/(w) * 2 h'f8 h'ff86 timer counter 3 (high) tcnt3h r/w h'00 h'ff87 timer counter 3 (low) tcnt3l r/w h'00 h'ff88 general register a3 (high) gra3h r/w h'ff h'ff89 general register a3 (low) gra3l r/w h'ff h'ff8a general register b3 (high) grb3h r/w h'ff h'ff8b general register b3 (low) grb3l r/w h'ff h'ff8c buffer register a3 (high) bra3h r/w h'ff h'ff8d buffer register a3 (low) bra3l r/w h'ff h'ff8e buffer register b3 (high) brb3h r/w h'ff h'ff8f buffer register b3 (low) brb3l r/w h'ff
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 203 of 682 rej09b0353-0300 channel address * 1 name abbre- viation r/w initial value 4 h'ff92 timer control register 4 tcr4 r/w h'80 h'ff93 timer i/o control register 4 tior4 r/w h'88 h'ff94 timer interrupt enable register 4 tier4 r/w h'f8 h'ff95 timer status register 4 tsr4 r/(w) * 2 h'f8 h'ff96 timer counter 4 (high) tcnt4h r/w h'00 h'ff97 timer counter 4 (low) tcnt4l r/w h'00 h'ff98 general register a4 (high) gra4h r/w h'ff h'ff99 general register a4 (low) gra4l r/w h'ff h'ff9a general register b4 (high) grb4h r/w h'ff h'ff9b general register b4 (low) grb4l r/w h'ff h'ff9c buffer register a4 (high) bra4h r/w h'ff h'ff9d buffer register a4 (low) bra4l r/w h'ff h'ff9e buffer register b4 (high) brb4h r/w h'ff h'ff9f buffer register b4 (low) brb4l r/w h'ff notes: 1. the lower 16 bits of the address are indicated. 2. only 0 can be written, to clear flags.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 204 of 682 rej09b0353-0300 8.2 register descriptions 8.2.1 timer start register (tstr) tstr is an 8-bit readable/writable register that starts and stops the timer counter (tcnt) in channels 0 to 4. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 str4 0 r/w 3 str3 0 r/w 2 str2 0 r/w 1 str1 0 r/w 0 str0 0 r/w reserved bits counter start 4 to 0 these bits start and stop tcnt4 to tcnt0 tstr is initialized to h'e0 by a reset and in standby mode. bits 7 to 5?reserved: these bits cannot be modified and are always read as 1. bit 4?counter start 4 (str4): starts and stops timer counter 4 (tcnt4). bit4 str4 description 0 tcnt4 is halted (initial value) 1 tcnt4 is counting bit 3?counter start 3 (str3): starts and stops timer counter 3 (tcnt3). bit 3 str3 description 0 tcnt3 is halted (initial value) 1 tcnt3 is counting
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 205 of 682 rej09b0353-0300 bit 2?counter start 2 (str2): starts and stops timer counter 2 (tcnt2). bit 2 str2 description 0 tcnt2 is halted (initial value) 1 tcnt2 is counting bit 1?counter start 1 (str1): starts and stops timer counter 1 (tcnt1). bit 1 str1 description 0 tcnt1 is halted (initial value) 1 tcnt1 is counting bit 0?counter start 0 (str0): starts and stops timer counter 0 (tcnt0). bit 0 str0 description 0 tcnt0 is halted (initial value) 1 tcnt0 is counting
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 206 of 682 rej09b0353-0300 8.2.2 timer synchro register (tsnc) tsnc is an 8-bit readable/writable register that selects whether channels 0 to 4 operate independently or synchronously. channels are synchronized by setting the corresponding bits to 1. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 sync4 0 r/w 3 sync3 0 r/w 2 sync2 0 r/w 1 sync1 0 r/w 0 sync0 0 r/w reserved bits timer sync 4 to 0 these bits synchronize channels 4 to 0 tsnc is initialized to h'e0 by a reset and in standby mode. bits 7 to 5?reserved: these bits cannot be modified and are always read as 1. bit 4?timer sync 4 (sync4): selects whether channel 4 operates independently or synchronously. bit 4 sync4 description 0 channel 4's timer counter (tcnt4) operates independently tcnt4 is preset and cleared independently of other channels (initial value) 1 channel 4 operates synchronously tcnt4 can be synchronously preset and cleared bit 3?timer sync 3 (sync3): selects whether channel 3 operates independently or synchronously. bit 3 sync3 description 0 channel 3's timer counter (tcnt3) operates independently tcnt3 is preset and cleared independently of other channels (initial value) 1 channel 3 operates synchronously tcnt3 can be synchronously preset and cleared
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 207 of 682 rej09b0353-0300 bit 2?timer sync 2 (sync2): selects whether channel 2 operates independently or synchronously. bit 2 sync2 description 0 channel 2's timer counter (tcnt2) operates independently tcnt2 is preset and cleared independently of other channels (initial value) 1 channel 2 operates synchronously tcnt2 can be synchronously preset and cleared bit 1?timer sync 1 (sync1): selects whether channel 1 operates independently or synchronously. bit 1 sync1 description 0 channel 1's timer counter (tcnt1) operates independently tcnt1 is preset and cleared independently of other channels (initial value) 1 channel 1 operates synchronously tcnt1 can be synchronously preset and cleared bit 0?timer sync 0 (sync0): selects whether channel 0 operates independently or synchronously. bit 0 sync0 description 0 channel 0's timer counter (tcnt0) operates independently tcnt0 is preset and cleared independently of other channels (initial value) 1 channel 0 operates synchronously tcnt0 can be synchronously preset and cleared
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 208 of 682 rej09b0353-0300 8.2.3 timer mode register (tmdr) tmdr is an 8-bit readable/writable register that selects pwm mode for channels 0 to 4. it also selects phase counting mode and the overflow flag (ovf) setting conditions for channel 2. bit initial value read/write 7 ? 1 ? 6 mdf 0 r/w 5 fdir 0 r/w 4 pwm4 0 r/w 3 pwm3 0 r/w 0 pwm0 0 r/w 2 pwm2 0 r/w 1 pwm1 0 r/w reserved bit pwm mode 4 to 0 these bits select pwm mode for channels 4 to 0 phase counting mode flag selects phase counting mode for channel 2 flag direction selects the setting condition for the overflow flag (ovf) in timer status register 2 (tsr2) tmdr is initialized to h'80 by a reset and in standby mode. bit 7?reserved: this bit cannot be modified and is always read as 1. bit 6?phase counting mode flag (mdf): selects whether channel 2 operates normally or in phase counting mode. bit 6 mdf description 0 channel 2 operates normally (initial value) 1 channel 2 operates in phase counting mode when mdf is set to 1 to select phase counting mode, timer counter 2 (tcnt2) operates as an up/down-counter and pins tclka and tclkb become counter clock input pins. tcnt2 counts both rising and falling edges of tclka and tclkb, and counts up or down as follows. counting direction down-counting up-counting tclka pin high low low high tclkb pin low high high low
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 209 of 682 rej09b0353-0300 in phase counting mode channel 2 operates as above regardless of the external clock edges selected by bits ckeg1 and ckeg0 and the clock source selected by bits tpsc2 to tpsc0 in timer control register 2 (tcr2). phase counting mode takes precedence over these settings. the counter clearing condition selected by the cclr1 and cclr0 bits in tcr2 and the compare match/input capture settings and interrupt functions of timer i/o control register 2 (tior2), timer interrupt enable register 2 (tier2), and timer status register 2 (tsr2) remain effective in phase counting mode. bit 5?flag direction (fdir): designates the setting condition for the overflow flag (ovf) in timer status register 2 (tsr2). the fdir designation is valid in all modes in channel 2. bit 5 fdir description 0 ovf is set to 1 in tsr2 when tcnt2 overflows or underflows (initial value) 1 ovf is set to 1 in tsr2 when tcnt2 overflows bit 4?pwm mode 4 (pwm4): selects whether channel 4 operates normally or in pwm mode. bit 4 pwm4 description 0 channel 4 operates normally (initial value) 1 channel 4 operates in pwm mode when bit pwm4 is set to 1 to select pwm mode, pin tioca4 becomes a pwm output pin. the output goes to 1 at compare match with general register a4 (gra4), and to 0 at compare match with general register b4 (grb4). if complementary pwm mode or reset-synchronized pwm mode is selected by bits cmd1 and cmd0 in the timer function control register (tfcr), the cmd1 and cmd0 setting takes precedence and the pwm4 setting is ignored. bit 3?pwm mode 3 (pwm3): selects whether channel 3 operates normally or in pwm mode. bit 3 pwm3 description 0 channel 3 operates normally (initial value) 1 channel 3 operates in pwm mode
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 210 of 682 rej09b0353-0300 when bit pwm3 is set to 1 to select pwm mode, pin tioca3 becomes a pwm output pin. the output goes to 1 at compare match with general register a3 (gra3), and to 0 at compare match with general register b3 (grb3). if complementary pwm mode or reset-synchronized pwm mode is selected by bits cmd1 and cmd0 in the timer function control register (tfcr), the cmd1 and cmd0 setting takes precedence and the pwm3 setting is ignored. bit 2?pwm mode 2 (pwm2): selects whether channel 2 operates normally or in pwm mode. bit 2 pwm2 description 0 channel 2 operates normally (initial value) 1 channel 2 operates in pwm mode when bit pwm2 is set to 1 to select pwm mode, pin tioca2 becomes a pwm output pin. the output goes to 1 at compare match with general register a2 (gra2), and to 0 at compare match with general register b2 (grb2). bit 1?pwm mode 1 (pwm1): selects whether channel 1 operates normally or in pwm mode. bit 1 pwm1 description 0 channel 1 operates normally (initial value) 1 channel 1 operates in pwm mode when bit pwm1 is set to 1 to select pwm mode, pin tioca1 becomes a pwm output pin. the output goes to 1 at compare match with general register a1 (gra1), and to 0 at compare match with general register b1 (grb1). bit 0?pwm mode 0 (pwm0): selects whether channel 0 operates normally or in pwm mode. bit 0 pwm0 description 0 channel 0 operates normally (initial value) 1 channel 0 operates in pwm mode when bit pwm0 is set to 1 to select pwm mode, pin tioca0 becomes a pwm output pin. the output goes to 1 at compare match with general register a0 (gra0), and to 0 at compare match with general register b0 (grb0).
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 211 of 682 rej09b0353-0300 8.2.4 timer function control register (tfcr) tfcr is an 8-bit readable/writable register that selects complementary pwm mode, reset- synchronized pwm mode, and buffering for channels 3 and 4. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 cmd1 0 r/w 4 cmd0 0 r/w 3 bfb4 0 r/w 0 bfa3 0 r/w 2 bfa4 0 r/w 1 bfb3 0 r/w reserved bits combination mode 1/0 these bits select complementary pwm mode or reset-synchronized pwm mode for channels 3 and 4 buffer mode b4 and a4 these bits select buffering of general registers (grb4 and gra4) by buffer registers (brb4 and bra4) in channel 4 buffer mode b3 and a3 these bits select buffering of general registers (grb3 and gra3) by buffer registers (brb3 and bra3) in channel 3 tfcr is initialized to h'c0 by a reset and in standby mode. bits 7 and 6?reserved: these bits cannot be modified and are always read as 1.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 212 of 682 rej09b0353-0300 bits 5 and 4?combination mode 1 and 0 (cmd1, cmd0): these bits select whether channels 3 and 4 operate in normal mode, complementary pwm mode, or reset-synchronized pwm mode. bit 5 cmd1 bit 4 cmd0 description 0 0 channels 3 and 4 operate normally (initial value) 1 1 0 channels 3 and 4 operate together in complementary pwm mode 1 channels 3 and 4 operate together in reset-synchronized pwm mode before selecting reset-synchronized pwm mode or complementary pwm mode, halt the timer counter or counters that will be used in these modes. when these bits select complementary pwm mode or reset-synchronized pwm mode, they take precedence over the setting of the pwm mode bits (pwm4 and pwm3) in tmdr. settings of timer sync bits sync4 and sync3 in the timer synchro register (tsnc) are valid in complementary pwm mode and reset-synchronized pwm mode, however. when complementary pwm mode is selected, channels 3 and 4 must not be synchronized (do not set bits sync3 and sync4 both to 1 in tsnc). bit 3?buffer mode b4 (bfb4): selects whether grb4 operates normally in channel 4, or whether grb4 is buffered by brb4. bit 3 bfb4 description 0 grb4 operates normally (initial value) 1 grb4 is buffered by brb4 bit 2?buffer mode a4 (bfa4): selects whether gra4 operates normally in channel 4, or whether gra4 is buffered by bra4. bit 2 bfa4 description 0 gra4 operates normally (initial value) 1 gra4 is buffered by bra4
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 213 of 682 rej09b0353-0300 bit 1?buffer mode b3 (bfb3): selects whether grb3 operates normally in channel 3, or whether grb3 is buffered by brb3. bit 1 bfb3 description 0 grb3 operates normally (initial value) 1 grb3 is buffered by brb3 bit 0?buffer mode a3 (bfa3): selects whether gra3 operates normally in channel 3, or whether gra3 is buffered by bra3. bit 0 bfa3 description 0 gra3 operates normally (initial value) 1 gra3 is buffered by bra3
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 214 of 682 rej09b0353-0300 8.2.5 timer output master enable register (toer) toer is an 8-bit readable/writable register that enables or disables output settings for channels 3 and 4. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 exb4 1 r/w 4 exa4 1 r/w 3 eb3 1 r/w 0 ea3 1 r/w 2 eb4 1 r/w 1 ea4 1 r/w reserved bits master enable tocxa 4 , tocxb 4 these bits enable or disable output settings for pins tocxa 4 and tocxb 4 master enable tioca 3 , tiocb 3 , tioca 4 , tiocb 4 these bits enable or disable output settings for pins tioca 3 , tiocb 3 , tioca 4 , and tiocb 4 toer is initialized to h'ff by a reset and in standby mode. bits 7 and 6?reserved: these bits cannot be modified and are always read as 1. bit 5?master enable tocxb 4 (exb4): enables or disables itu output at pin tocxb 4 . bit 5 exb4 description 0tocxb 4 output is disabled regardless of tfcr settings (tocxb 4 operates as a generic input/output pin). if xtgd = 0, exb4 is cleared to 0 when input capture a occurs in channel 1. 1tocxb 4 is enabled for output according to tfcr settings (initial value) bit 4?master enable tocxa 4 (exa4): enables or disables itu output at pin tocxa 4 . bit 4 exa4 description 0tocxa 4 output is disabled regardless of tfcr settings (tocxa 4 operates as a generic input/output pin). if xtgd = 0, exa4 is cleared to 0 when input capture a occurs in channel 1. 1tocxa 4 is enabled for output according to tfcr settings (initial value)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 215 of 682 rej09b0353-0300 bit 3?master enable tiocb 3 (eb3): enables or disables itu output at pin tiocb 3 . bit 3 eb3 description 0tiocb 3 output is disabled regardless of tior3 and tfcr settings (tiocb 3 operates as a generic input/output pin). if xtgd = 0, eb3 is cleared to 0 when input capture a occurs in channel 1. 1tiocb 3 is enabled for output according to tior3 and tfcr settings (initial value) bit 2?master enable tiocb 4 (eb4): enables or disables itu output at pin tiocb 4 . bit 2 eb4 description 0tiocb 4 output is disabled regardless of tior4 and tfcr settings (tiocb 4 operates as a generic input/output pin). if xtgd = 0, eb4 is cleared to 0 when input capture a occurs in channel 1. 1tiocb 4 is enabled for output according to tior4 and tfcr settings (initial value) bit 1?master enable tioca 4 (ea4): enables or disables itu output at pin tioca 4 . bit 1 ea4 description 0tioca 4 output is disabled regardless of tior4, tmdr, and tfcr settings (tioca 4 operates as a generic input/output pin). if xtgd = 0, ea4 is cleared to 0 when input capture a occurs in channel 1. 1tioca 4 is enabled for output according to tior4, tmdr, and tfcr settings (initial value) bit 0?master enable tioca 3 (ea3): enables or disables itu output at pin tioca 3 . bit 0 ea3 description 0tioca 3 output is disabled regardless of tior3, tmdr, and tfcr settings (tioca 3 operates as a generic input/output pin). if xtgd = 0, ea3 is cleared to 0 when input capture a occurs in channel 1. 1tioca 3 is enabled for output according to tior3, tmdr, and tfcr settings (initial value)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 216 of 682 rej09b0353-0300 8.2.6 timer output control register (tocr) tocr is an 8-bit readable/writable register that selects externally triggered disabling of output in complementary pwm mode and reset-synchronized pwm mode, and inverts the output levels. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 xtgd 1 r/w 3 ? 1 ? 0 ols3 1 r/w 2 ? 1 ? 1 ols4 1 r/w reserved bits output level select 3, 4 these bits select output levels in complementary pwm mode and reset- synchronized pwm mode external trigger disable selects externally triggered disabling of output in complementary pwm mode and reset-synchronized pwm mode reserved bits the settings of the xtgd, ols4, and ols3 bits are valid only in complementary pwm mode and reset-synchronized pwm mode. these settings do not affect other modes. tocr is initialized to h'ff by a reset and in standby mode. bits 7 to 5?reserved: these bits cannot be modified and are always read as 1. bit 4?external trigger disable (xtgd): selects externally triggered disabling of itu output in complementary pwm mode and reset-synchronized pwm mode. bit 4 xtgd description 0 input capture a in channel 1 is used as an external trigger signal in complementary pwm mode and reset-synchronized pwm mode. when an external trigger occurs, bits 5 to 0 in the timer output master enable register (toer) are cleared to 0, disabling itu output. 1 external triggering is disabled (initial value)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 217 of 682 rej09b0353-0300 bits 3 and 2?reserved: these bits cannot be modified and are always read as 1. bit 1?output level select 4 (ols4): selects output levels in complementary pwm mode and reset-synchronized pwm mode. bit 1 ols4 description 0tioca 3 , tioca 4 , and tiocb 4 pin outputs are inverted 1tioca 3 , tioca 4 , and tiocb 4 pin outputs are not inverted (initial value) bit 0?output level select 3 (ols3): selects output levels in complementary pwm mode and reset-synchronized pwm mode. bit 0 ols3 description 0tiocb 3 , tocxa 4 , and tocxb 4 pin outputs are inverted 1tiocb 3 , tocxa 4 , and tocxb 4 pin outputs are not inverted (initial value)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 218 of 682 rej09b0353-0300 8.2.7 timer counters (tcnt) tcnt is a 16-bit counter. the itu has five tcnts, one for each channel. channel abbreviation function 0 tcnt0 1 tcnt1 up-counter 2 tcnt2 phase counting mode: up/down-counter other modes: up-counter 3 tcnt3 4 tcnt4 complementary pwm mode: up/down-counter other modes: up-counter bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w each tcnt is a 16-bit readable/writable register that counts pulse inputs from a clock source. the clock source is selected by bits tpsc2 to tpsc0 in the timer control register (tcr). tcnt0 and tcnt1 are up-counters. tcnt2 is an up/down-counter in phase counting mode and an up-counter in other modes. tcnt3 and tcnt4 are up/down-counters in complementary pwm mode and up-counters in other modes. tcnt can be cleared to h'0000 by compare match with general register a or b (gra or grb) or by input capture to gra or grb (counter clearing function) in the same channel. when tcnt overflows (changes from h'ffff to h'0000), the overflow flag (ovf) is set to 1 in the timer status register (tsr) of the corresponding channel. when tcnt underflows (changes from h'0000 to h'ffff), the overflow flag (ovf) is set to 1 in tsr of the corresponding channel. the tcnts are linked to the cpu by an internal 16-bit bus and can be written or read by either word access or byte access. each tcnt is initialized to h'0000 by a reset and in standby mode.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 219 of 682 rej09b0353-0300 8.2.8 general registers (gra, grb) the general registers are 16-bit registers. the itu has 10 general registers, two in each channel. channel abbreviation function 0gra0, grb0 1gra1, grb1 2gra2, grb2 output compare/input capture register 3gra3, grb3 4gra4, grb4 output compare/input capture register; can be by buffer registers bra and brb bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w a general register is a 16-bit readable/writable register that can function as either an output compare register or an input capture register. the function is selected by settings in the timer i/o control register (tior). when a general register is used as an output compare register, its value is constantly compared with the tcnt value. when the two values match (compare match), the imfa or imfb flag is set to 1 in the timer status register (tsr). compare match output can be selected in tior. when a general register is used as an input capture register, rising edges, falling edges, or both edges of an external input capture signal are detected and the current tcnt value is stored in the general register. the corresponding imfa or imfb flag in tsr is set to 1 at the same time. the valid edge or edges of the input capture signal are selected in tior. tior settings are ignored in pwm mode, complementary pwm mode, and reset-synchronized pwm mode. general registers are linked to the cpu by an internal 16-bit bus and can be written or read by either word access or byte access. general registers are initialized to the output compare function (with no output signal) by a reset and in standby mode. the initial value is h'ffff.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 220 of 682 rej09b0353-0300 8.2.9 buffer registers (bra, brb) the buffer registers are 16-bit registers. the itu has four buffer registers, two each in channels 3 and 4. channel abbreviation function 3 bra3, brb3 4 bra4, brb4 used for buffering ? when the corresponding gra or grb functions as an output compare register, bra or brb can function as an output compare buffer register: the bra or brb value is automatically transferred to gra or grb at compare match ? when the corresponding gra or grb functions as an input capture register, bra or brb can function as an input capture buffer register: the gra or grb value is automatically transferred to bra or brb at input capture bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w a buffer register is a 16-bit readable/writable register that is used when buffering is selected. buffering can be selected independently by bits bfb4, bfa4, bfb3, and bfa3 in tfcr. the buffer register and general register operate as a pair. when the general register functions as an output compare register, the buffer register functions as an output compare buffer register. when the general register functions as an input capture register, the buffer register functions as an input capture buffer register. the buffer registers are linked to the cpu by an internal 16-bit bus and can be written or read by either word or byte access. buffer registers are initialized to h'ffff by a reset and in standby mode.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 221 of 682 rej09b0353-0300 8.2.10 timer control registers (tcr) tcr is an 8-bit register. the itu has five tcrs, one in each channel. channel abbreviation function 0 tcr0 1 tcr1 2 tcr2 3 tcr3 4 tcr4 tcr controls the timer counter. the tcrs in all channels are functionally identical. when phase counting mode is selected in channel 2, the settings of bits ckeg1 and ckeg0 and tpsc2 to tpsc0 in tcr2 are ignored. bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 ckeg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w timer prescaler 2 to 0 these bits select the counter clock reserved bit clock edge 1/0 these bits select external clock edges counter clear 1/0 these bits select the counter clear source each tcr is an 8-bit readable/writable register that selects the timer counter clock source, selects the edge or edges of external clock sources, and selects how the counter is cleared. tcr is initialized to h'80 by a reset and in standby mode. bit 7?reserved: this bit cannot be modified and is always read as 1. bits 6 and 5?counter clear 1/0 (cclr1, cclr0): these bits select how tcnt is cleared.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 222 of 682 rej09b0353-0300 bit 6 cclr1 bit 5 cclr0 description 0 0 tcnt is not cleared (initial value) 1 tcnt is cleared by gra compare match or input capture * 1 1 0 tcnt is cleared by grb compare match or input capture * 1 1 synchronous clear: tcnt is cleared in synchronization with other synchronized timers * 2 notes: 1. tcnt is cleared by compare match when the general register functions as an output compare match register, and by input capture when the general register functions as an input capture register. 2. selected in the timer synchro register (tsnc). bits 4 and 3?clock edge 1/0 (ckeg1, ckeg0): these bits select external clock input edges when an external clock source is used. bit 4 ckeg1 bit 3 ckeg0 description 0 0 count rising edges (initial value) 1 count falling edges 1 ? count both edges when channel 2 is set to phase counting mode, bits ckeg1 and ckeg0 in tcr2 are ignored. phase counting takes precedence. bits 2 to 0?timer prescaler 2 to 0 (tpsc2 to tpsc0): these bits select the counter clock source. bit 2 tpsc2 bit 1 tpsc1 bit 0 tpsc0 function 000internal clock:
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 223 of 682 rej09b0353-0300 when bit tpsc2 is cleared to 0 an internal clock source is selected, and the timer counts only falling edges. when bit tpsc2 is set to 1 an external clock source is selected, and the timer counts the edge or edges selected by bits ckeg1 and ckeg0. when channel 2 is set to phase counting mode (mdf = 1 in tmdr), the settings of bits tpsc2 to tpsc0 in tcr2 are ignored. phase counting takes precedence. 8.2.11 timer i/o control register (tior) tior is an 8-bit register. the itu has five tiors, one in each channel. channel abbreviation function 0tior0 1tior1 2tior2 3tior3 4tior4 tior controls the general registers. some functions differ in pwm mode. tior3 and tior4 settings are ignored when complementary pwm mode or reset-synchronized pwm mode is selected in channels 3 and 4. bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w i/o control a2 to a0 these bits select gra functions reserved bit i/o control b2 to b0 these bits select grb functions reserved bit each tior is an 8-bit readable/writable register that selects the output compare or input capture function for gra and grb, and specifies the functions of the tioca and tiocb pins. if the output compare function is selected, tior also selects the type of output. if input capture is selected, tior also selects the edge or edges of the input capture signal. tior is initialized to h'88 by a reset and in standby mode.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 224 of 682 rej09b0353-0300 bit 7?reserved: this bit cannot be modified and is always read as 1. bits 6 to 4?i/o control b2 to b0 (iob2 to iob0): these bits select the grb function. bit 6 iob2 bit 5 iob1 bit 4 iob0 function 0 0 0 no output at compare match (initial value) 1 grb is an output compare register 0 output at grb compare match * 1 1 0 1 output at grb compare match * 1 1 output toggles at grb compare match (1 output in channel 2) * 1 * 2 1 0 0 grb captures rising edge of input 1 grb captures falling edge of input 10 1 grb is an input capture register grb captures both edges of input notes: 1. after a reset, the output is 0 until the first compare match. 2. channel 2 output cannot be toggled by compare match. this setting selects 1 output instead. bit 3?reserved: this bit cannot be modified and is always read as 1. bits 2 to 0?i/o control a2 to a0 (ioa2 to ioa0): these bits select the gra function. bit 2 ioa2 bit 1 ioa1 bit 0 ioa0 function 0 0 0 no output at compare match (initial value) 1 0 output at gra compare match * 1 10 gra is an output compare register 1 output at gra compare match * 1 1 output toggles at gra compare match (1 output in channel 2) * 1 * 2 1 0 0 gra captures rising edge of input 1 gra captures falling edge of input 10 1 gra is an input capture register gra captures both edges of input notes: 1. after a reset, the output is 0 until the first compare match. 2. channel 2 output cannot be toggled by compare match. this setting selects 1 output instead.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 225 of 682 rej09b0353-0300 8.2.12 timer status register (tsr) tsr is an 8-bit register. the itu has five tsrs, one in each channel. channel abbreviation function 0tsr0 1tsr1 2tsr2 3tsr3 4tsr4 indicates input capture, compare match, and overflow status bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? * 2 ovf 0 r/(w) reserved bits note: * only 0 can be written to clear the flag. * 1 imfb 0 r/(w) * 0 imfa 0 r/(w) overflow flag status flag indicating overflow or underflow input capture/compare match flag b status flag indicating grb compare match or input capture input capture/compare match flag a status flag indicating gra compare match or input capture each tsr is an 8-bit readable/writable register containing flags that indicate tcnt overflow or underflow and gra or grb compare match or input capture. these flags are interrupt sources and generate cpu interrupts if enabled by corresponding bits in the timer interrupt enable register (tier). tsr is initialized to h'f8 by a reset and in standby mode. bits 7 to 3?reserved: these bits cannot be modified and are always read as 1.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 226 of 682 rej09b0353-0300 bit 2?overflow flag (ovf): this status flag indicates tcnt overflow or underflow. bit 2 ovf description 0 [clearing condition] (initial value) read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] tcnt overflowed from h'ffff to h'0000, or underflowed from h'0000 to h'ffff * notes: * tcnt underflow occurs when tcnt operates as an up/down-counter. underflow occurs only under the following conditions: 1. channel 2 operates in phase counting mode (mdf = 1 in tmdr) 2. channels 3 and 4 operate in complementary pwm mode (cmd1 = 1 and cmd0 = 0 in tfcr) bit 1?input capture/compare match flag b (imfb): this status flag indicates grb compare match or input capture events. bit 1 imfb description 0 [clearing condition] read imfb when imfb = 1, then write 0 in imfb (initial value) 1 [setting conditions] ? tcnt = grb when grb functions as a compare match register. ? tcnt value is transferred to grb by an input capture signal, when grb functions as an input capture register. bit 0?input capture/compare match flag a (imfa): this status flag indicates gra compare match or input capture events. bit 0 imfa description 0 [clearing condition] read imfa when imfa = 1, then write 0 in imfa. (initial value) 1 [setting conditions] ? tcnt = gra when gra functions as a compare match register. ? tcnt value is transferred to gra by an input capture signal, when gra functions as an input capture register.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 227 of 682 rej09b0353-0300 8.2.13 timer interrupt enable register (tier) tier is an 8-bit register. the itu has five tiers, one in each channel. channel abbreviation function 0 tier0 enables or disables interrupt requests. 1tier1 2tier2 3tier3 4tier4 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 2 ovie 0 r/w 1 imieb 0 r/w 0 imiea 0 r/w reserved bits overflow interrupt enable enables or disables ovf interrupts input capture/compare match interrupt enable b enables or disables imfb interrupts input capture/compare match interrupt enable a enables or disables imfa interrupts each tier is an 8-bit readable/writable register that enables and disables overflow interrupt requests and general register compare match and input capture interrupt requests. tier is initialized to h'f8 by a reset and in standby mode. bits 7 to 3?reserved: these bits cannot be modified and are always read as 1.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 228 of 682 rej09b0353-0300 bit 2?overflow interrupt enable (ovie): enables or disables the interrupt requested by the overflow flag (ovf) in tsr when ovf is set to 1. bit 2 ovie description 0 ovi interrupt requested by ovf is disabled (initial value) 1 ovi interrupt requested by ovf is enabled bit 1?input capture/compare match interrupt enable b (imieb): enables or disables the interrupt requested by the imfb flag in tsr when imfb is set to 1. bit 1 imieb description 0 imib interrupt requested by imfb is disabled (initial value) 1 imib interrupt requested by imfb is enabled bit 0?input capture/compare match interrupt enable a (imiea): enables or disables the interrupt requested by the imfa flag in tsr when imfa is set to 1. bit 0 imiea description 0 imia interrupt requested by imfa is disabled (initial value) 1 imia interrupt requested by imfa is enabled 8.3 cpu interface 8.3.1 16-bit accessible registers the timer counters (tcnts), general registers a and b (gras and grbs), and buffer registers a and b (bras and brbs) are 16-bit registers, and are linked to the cpu by an internal 16-bit data bus. these registers can be written or read a word at a time, or a byte at a time. figures 8.6 and 8.7 show examples of word access to a timer counter (tcnt). figures 8.8, 8.9, 8.10, and 8.11 show examples of byte access to tcnth and tcntl.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 229 of 682 rej09b0353-0300 internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.6 access to timer counter (cpu writes to tcnt, word) internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.7 access to timer counter (cpu reads tcnt, word) internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.8 access to timer counter (cpu writes to tcnt, upper byte)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 230 of 682 rej09b0353-0300 internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.9 access to timer counter (cpu writes to tcnt, lower byte) internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.10 access to timer counter (cpu reads tcnt, upper byte) internal data bus cpu h l bus interface h l module data bus tcnth tcntl figure 8.11 access to timer counter (cpu reads tcnt, lower byte)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 231 of 682 rej09b0353-0300 8.3.2 8-bit accessible registers the registers other than the timer counters, general registers, and buffer registers are 8-bit registers. these registers are linked to the cpu by an internal 8-bit data bus. figures 8.12 and 8.13 show examples of byte read and write access to a tcr. if a word-size data transfer instruction is executed, two byte transfers are performed. internal data bus cpu h l bus interface h l module data bus tcr figure 8.12 tcr access (cpu writes to tcr) internal data bus cpu h l bus interface h l module data bus tcr figure 8.13 tcr access (cpu reads tcr)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 232 of 682 rej09b0353-0300 8.4 operation 8.4.1 overview a summary of operations in the various modes is given below. normal operation: each channel has a timer counter and general registers. the timer counter counts up, and can operate as a free-running counter, periodic counter, or external event counter. general registers a and b can be used for input capture or output compare. synchronous operation: the timer counters in designated channels are preset synchronously. data written to the timer counter in any one of these channels is simultaneously written to the timer counters in the other channels as well. the timer counters can also be cleared synchronously if so designated by the cclr1 and cclr0 bits in the tcrs. pwm mode: a pwm waveform is output from the tioca pin. the output goes to 1 at compare match a and to 0 at compare match b. the duty cycle can be varied from 0 % to 100 % depending on the settings of gra and grb. when a channel is set to pwm mode, its gra and grb automatically become output compare registers. reset-synchronized pwm mode: channels 3 and 4 are paired for three-phase pwm output with complementary waveforms. (the three phases are related by having a common transition point.) when reset-synchronized pwm mode is selected gra3, grb3, gra4, and grb4 automatically function as output compare registers, tioca 3 , tiocb 3 , tioca 4 , tocxa 4 , tiocb 4 , and tocxb 4 function as pwm output pins, and tcnt 3 operates as an up-counter. tcnt4 operates independently, and is not compared with gra4 or grb4. complementary pwm mode: channels 3 and 4 are paired for three-phase pwm output with non-overlapping complementary waveforms. when complementary pwm mode is selected gra3, grb3, gra4, and grb4 automatically function as output compare registers, and tioca 3 , tiocb 3 , tioca 4 , tocxa 4 , tiocb 4 , and tocxb 4 function as pwm output pins. tcnt3 and tcnt4 operate as up/down-counters. phase counting mode: the phase relationship between two clock signals input at tclka and tclkb is detected and tcnt2 counts up or down accordingly. when phase counting mode is selected tclka and tclkb become clock input pins and tcnt2 operates as an up/down- counter.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 233 of 682 rej09b0353-0300 buffering: ? if the general register is an output compare register when compare match occurs the buffer register value is transferred to the general register. ? if the general register is an input capture register when input capture occurs the tcnt value is transferred to the general register, and the previous general register value is transferred to the buffer register. ? complementary pwm mode the buffer register value is transferred to the general register when tcnt3 and tcnt4 change counting direction. ? reset-synchronized pwm mode the buffer register value is transferred to the general register at gra3 compare match.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 234 of 682 rej09b0353-0300 8.4.2 basic functions counter operation when one of bits str0 to str4 is set to 1 in the timer start register (tstr), the timer counter (tcnt) in the corresponding channel starts counting. the counting can be free-running or periodic. sample setup procedure for counter: figure 8.14 shows a sample procedure for setting up a counter. counter setup select counter clock type of counting? periodic counting select counter clear source select output compare register function set period start counter free-running counting start counter periodic counter free-running counter 1 2 3 4 55 yes no figure 8.14 counter setup procedure (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 235 of 682 rej09b0353-0300 1. set bits tpsc2 to tpsc0 in tcr to select the counter clock source. if an external clock source is selected, set bits ckeg1 and ckeg0 in tcr to select the desired edge(s) of the external clock signal. 2. for periodic counting, set cclr1 and cclr0 in tcr to have tcnt cleared at gra compare match or grb compare match. 3. set tior to select the output compare function of gra or grb, whichever was selected in step 2. 4. write the count period in gra or grb, whichever was selected in step 2. 5. set the str bit to 1 in tstr to start the timer counter. free-running and periodic counter operation: a reset leaves the counters (tcnts) in itu channels 0 to 4 all set as free-running counters. a free-running counter starts counting up when the corresponding bit in tstr is set to 1. when the count overflows from h'ffff to h'0000, the overflow flag (ovf) is set to 1 in the timer status register (tsr). if the corresponding ovie bit is set to 1 in the timer interrupt enable register, a cpu interrupt is requested. after the overflow, the counter continues counting up from h'0000. figure 8.15 illustrates free-running counting. tcnt value h'ffff h'0000 str0 to str4 bit ovf time figure 8.15 free-running counter operation when a channel is set to have its counter cleared by compare match, in that channel tcnt operates as a periodic counter. select the output compare function of gra or grb, set bit cclr1 or cclr0 in the timer control register (tcr) to have the counter cleared by compare match, and set the count period in gra or grb. after these settings, the counter starts counting up as a periodic counter when the corresponding bit is set to 1 in tstr. when the count matches gra or grb, the imfa or imfb flag is set to 1 in tsr and the counter is cleared to h'0000. if the corresponding imiea or imieb bit is set to 1 in tier, a cpu interrupt is requested at this time. after the compare match, tcnt continues counting up from h'0000. figure 8.16 illustrates periodic counting.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 236 of 682 rej09b0353-0300 tcnt value gr h'0000 str bit imf time counter cleared by general register compare match figure 8.16 periodic counter operation count timing: ? internal clock source bits tpsc2 to tpsc0 in tcr select the system clock ( ) or one of three internal clock sources obtained by prescaling the system clock ( /2, /4, /8). figure 8.17 shows the timing. ? 1 n n + 1 figure 8.17 count timing for internal clock sources ? external clock source bits tpsc2 to tpsc0 in tcr select an external clock input pin (tclka to tclkd), and its valid edge or edges are selected by bits ckeg1 and ckeg0. the rising edge, falling edge, or both edges can be selected. the pulse width of the external clock signal must be at least 1.5 system clocks when a single edge is selected, and at least 2.5 system clocks when both edges are selected. shorter pulses will not be counted correctly. figure 8.18 shows the timing when both edges are detected.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 237 of 682 rej09b0353-0300 ? 1 n n + 1 figure 8.18 count timing for external clock sources (when both edges are detected) waveform output by compare match in itu channels 0, 1, 3, and 4, compare match a or b can cause the output at the tioca or tiocb pin to go to 0, go to 1, or toggle. in channel 2 the output can only go to 0 or go to 1. sample setup procedure for waveform output by compare match: figure 8.19 shows a sample procedure for setting up waveform output by compare match. output setup select waveform output mode set output timing start counter waveform output select the compare match output mode (0, 1, or toggle) in tior. when a waveform output mode is selected, the pin switches from its generic input/ output function to the output compare function (tioca or tiocb). an output compare pin outputs set a value in gra or grb to designate the compare match timing. set the str bit to 1 in tstr to start the timer counter. 1 2 3 0 until the first compare match occurs. 1. 2. 3. figure 8.19 setup procedure for waveform output by compare match (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 238 of 682 rej09b0353-0300 examples of waveform output: figure 8.20 shows examples of 0 and 1 output. tcnt operates as a free-running counter, 0 output is selected for compare match a, and 1 output is selected for compare match b. when the pin is already at the selected output level, the pin level does not change. time h'ffff grb tiocb tioca gra no change no change no change no change 1 output 0 output tcnt value h'0000 figure 8.20 0 and 1 output (examples) figure 8.21 shows examples of toggle output. tcnt operates as a periodic counter, cleared by compare match b. toggle output is selected for both compare match a and b. grb tiocb tioca gra tcnt value time counter cleared by compare match with grb toggle output toggle output h'0000 figure 8.21 toggle output (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 239 of 682 rej09b0353-0300 output compare timing: the compare match signal is generated in the last state in which tcnt and the general register match (when tcnt changes from the matching value to the next value). when the compare match signal is generated, the output value selected in tior is output at the output compare pin (tioca or tiocb). when tcnt matches a general register, the compare match signal is not generated until the next counter clock pulse. figure 8.22 shows the output compare timing. n + 1 n n figure 8.22 output compare timing
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 240 of 682 rej09b0353-0300 input capture function the tcnt value can be captured into a general register when a transition occurs at an input capture/output compare pin (tioca or tiocb). capture can take place on the rising edge, falling edge, or both edges. the input capture function can be used to measure pulse width or period. sample setup procedure for input capture: figure 8.23 shows a sample procedure for setting up input capture. input selection select input-capture input start counter input capture set tior to select the input capture function of a general register and the rising edge, falling edge, or both edges of the input capture signal. clear the port data direction bit to 0 before making these tior settings. set the str bit to 1 in tstr to start the timer counter. 1 2 1. 2. figure 8.23 setup procedure for input capture (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 241 of 682 rej09b0353-0300 examples of input capture: figure 8.24 illustrates input capture when the falling edge of tiocb and both edges of tioca are selected as capture edges. tcnt is cleared by input capture into grb. h'0005 h'0180 time h'0180 h'0160 h'0005 h'0000 tiocb tioca gra grb counter cleared by tiocb input (falling edge) tcnt value h'0160 figure 8.24 input capture (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 242 of 682 rej09b0353-0300 input capture signal timing: input capture on the rising edge, falling edge, or both edges can be selected by settings in tior. figure 8.25 shows the timing when the rising edge is selected. the pulse width of the input capture signal must be at least 1.5 system clocks for single-edge capture, and 2.5 system clocks for capture of both edges. n n figure 8.25 input capture signal timing
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 243 of 682 rej09b0353-0300 8.4.3 synchronization the synchronization function enables two or more timer counters to be synchronized by writing the same data to them simultaneously (synchronous preset). with appropriate tcr settings, two or more timer counters can also be cleared simultaneously (synchronous clear). synchronization enables additional general registers to be associated with a single time base. synchronization can be selected for all channels (0 to 4). sample setup procedure for synchronization figure 8.26 shows a sample procedure for setting up synchronization. setup for synchronization synchronous preset set the sync bits to 1 in tsnc for the channels to be synchronized. when a value is written in tcnt in one of the synchronized channels, the same value is simultaneously written in tcnt in the other channels. 1. 2. 2 3 1 5 4 5 select synchronization synchronous preset write to tcnt synchronous clear clearing synchronized to this channel? select counter clear source start counter counter clear synchronous clear start counter select counter clear source ye s no set the cclr1 or cclr0 bit in tcr to have the counter cleared by compare match or input capture. set the cclr1 and cclr0 bits in tcr to have the counter cleared synchronously. set the str bits in tstr to 1 to start the synchronized counters. 3. 4. 5. figure 8.26 setup procedure for synchronization (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 244 of 682 rej09b0353-0300 example of synchronization figure 8.27 shows an example of synchronization. channels 0, 1, and 2 are synchronized, and are set to operate in pwm mode. channel 0 is set for counter clearing by compare match with grb0. channels 1 and 2 are set for synchronous counter clearing. the timer counters in channels 0, 1, and 2 are synchronously preset, and are synchronously cleared by compare match with grb0. a three-phase pwm waveform is output from pins tioca 0 , tioca 1 , and tioca 2 . for further information on pwm mode, see section 8.4.4, pwm mode. tioca 2 time tioca 1 tioca 0 gra2 h'0000 gra1 grb2 gra0 grb1 grb0 value of tcnt0 to tcnt2 cleared by compare match with grb0 figure 8.27 synchronization (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 245 of 682 rej09b0353-0300 8.4.4 pwm mode in pwm mode gra and grb are paired and a pwm waveform is output from the tioca pin. gra specifies the time at which the pwm output changes to 1. grb specifies the time at which the pwm output changes to 0. if either gra or grb is selected as the counter clear source, a pwm waveform with a duty cycle from 0 % to 100 % is output at the tioca pin. pwm mode can be selected in all channels (0 to 4). table 8.4 summarizes the pwm output pins and corresponding registers. if the same value is set in gra and grb, the output does not change when compare match occurs. table 8.4 pwm output pins and registers channel output pin 1 output 0 output 0tioca 0 gra0 grb0 1tioca 1 gra1 grb1 2tioca 2 gra2 grb2 3tioca 3 gra3 grb3 4tioca 4 gra4 grb4
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 246 of 682 rej09b0353-0300 sample setup procedure for pwm mode figure 8.28 shows a sample procedure for setting up pwm mode. pwm mode 1. set bits tpsc2 to tpsc0 in tcr to select the counter clock source. if an external clock source is selected, set bits ckeg1 and ckeg0 in tcr to select the desired edge(s) of the external clock signal. pwm mode select counter clock 1 select counter clear source 2 set gra 3 set grb 4 select pwm mode 5 start counter 6 2. set bits cclr1 and cclr0 in tcr to select the counter clear source. 3. set the time at which the pwm waveform should go to 1 in gra. 4. set the time at which the pwm waveform should go to 0 in grb. 5. set the pwm bit in tmdr to select pwm mode. when pwm mode is selected, regardless of the tior contents, gra and grb become output compare registers specifying the times at which the pwm goes to 1 and 0. the tioca pin automatically becomes the pwm output pin. the tiocb pin conforms to the settings of bits iob1 and iob0 in tior. if tiocb output is not desired, clear both iob1 and iob0 to 0. 6. set the str bit to 1 in tstr to start the timer counter. figure 8.28 setup procedure for pwm mode (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 247 of 682 rej09b0353-0300 examples of pwm mode figure 8.29 shows examples of operation in pwm mode. the pwm waveform is output from the tioca pin. the output goes to 1 at compare match with gra, and to 0 at compare match with grb. in the examples shown, tcnt is cleared by compare match with gra or grb. synchronized operation and free-running counting are also possible. tcnt value counter cleared by compare match with gra time gra grb tioca a. counter cleared by gra tcnt value counter cleared by compare match with grb time grb gra tioca b. counter cleared by grb h'0000 h'0000 figure 8.29 pwm mode (example 1)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 248 of 682 rej09b0353-0300 figure 8.30 shows examples of the output of pwm waveforms with duty cycles of 0 % and 100 % . if the counter is cleared by compare match with grb, and gra is set to a higher value than grb, the duty cycle is 0 % . if the counter is cleared by compare match with gra, and grb is set to a higher value than gra, the duty cycle is 100 % . tcnt value counter cleared by compare match with grb time grb gra tioca a. 0% duty cycle tcnt value counter cleared by compare match with gra time gra grb tioca b. 100% duty cycle write to gra write to gra write to grb write to grb h'0000 h'0000 figure 8.30 pwm mode (example 2)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 249 of 682 rej09b0353-0300 8.4.5 reset-synchronized pwm mode in reset-synchronized pwm mode channels 3 and 4 are combined to produce three pairs of complementary pwm waveforms, all having one waveform transition point in common. when reset-synchronized pwm mode is selected tioca 3 , tiocb 3 , tioca 4 , tocxa 4 , tiocb 4 , and tocxb 4 automatically become pwm output pins, and tcnt 3 functions as an up-counter. table 8.5 lists the pwm output pins. table 8.6 summarizes the register settings. table 8.5 output pins in reset-synchronized pwm mode channel output pin description 3tioca 3 pwm output 1 tiocb 3 pwm output 1' (complementary waveform to pwm output 1) 4tioca 4 pwm output 2 tocxa 4 pwm output 2' (complementary waveform to pwm output 2) tiocb 4 pwm output 3 tocxb 4 pwm output 3' (complementary waveform to pwm output 3) table 8.6 register settings in reset-synchronized pwm mode register setting tcnt3 initially set to h'0000 tcnt4 not used (operates independently) gra3 specifies the count period of tcnt3 grb3 specifies a transition point of pwm waveforms output from tioca 3 and tiocb 3 gra4 specifies a transition point of pwm waveforms output from tioca 4 and tocxa 4 grb4 specifies a transition point of pwm waveforms output from tiocb 4 and tocxb 4
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 250 of 682 rej09b0353-0300 sample setup procedure for reset-synchronized pwm mode figure 8.31 shows a sample procedure for setting up reset-synchronized pwm mode. reset-synchronized pwm mode 1. clear the str3 bit in tstr to 0 to halt tcnt3. reset-synchronized pwm mode must be set up while tcnt3 is halted. reset-synchronized pwm mode stop counter 1 select counter clock 2 select counter clear source 3 select reset-synchronized pwm mode 4 set tcnt 5 set general registers 6 2. set bits tpsc2 to tpsc0 in tcr to select the counter clock source for channel 3. if an external clock source is selected, select the external clock edge(s) with bits ckeg1 and ckeg0 in tcr. 3. set bits cclr1 and cclr0 in tcr3 to select gra3 compare match as the counter clear source. 4. set bits cmd1 and cmd0 in tfcr to select reset-synchronized pwm mode. tioca 3 , tiocb 3 , tioca 4 , tiocb 4 , tocxa 4 , and tocxb 4 automatically become pwm output pins. 5. preset tcnt3 to h'0000. tcnt4 need not be preset. start counter 7 6. gra3 is the waveform period register. set the waveform period value in gra3. set transition times of the pwm output waveforms in grb3, gra4, and grb4. set times within the compare match range of tcnt3. x gra3 (x: setting value) figure 8.31 setup procedure for reset-synchronized pwm mode (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 251 of 682 rej09b0353-0300 example of reset-synchronized pwm mode figure 8.32 shows an example of operation in reset-synchronized pwm mode. tcnt3 operates as an up-counter in this mode. tcnt4 operates independently, detached from gra4 and grb4. when tcnt3 matches gra3, tcnt3 is cleared and resumes counting from h'0000. the pwm outputs toggle at compare match with grb3, gra4, grb4, and tcnt3 respectively, and when the counter is cleared. tcnt3 value counter cleared at compare match with gra3 time gra3 grb3 gra4 grb4 h'0000 tioca 3 tiocb 3 tioca 4 tocxa 4 tiocb 4 tocxb 4 figure 8.32 operation in reset-synchronized pwm mode (example) (when ols3 = ols4 = 1) for the settings and operation when reset-synchronized pwm mode and buffer mode are both selected, see section 8.4.8, buffering.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 252 of 682 rej09b0353-0300 8.4.6 complementary pwm mode in complementary pwm mode channels 3 and 4 are combined to output three pairs of complementary, non-overlapping pwm waveforms. when complementary pwm mode is selected tioca 3 , tiocb 3 , tioca 4 , tocxa 4 , tiocb 4 , and tocxb 4 automatically become pwm output pins, and tcnt3 and tcnt4 function as up/down- counters. table 8.7 lists the pwm output pins. table 8.8 summarizes the register settings. table 8.7 output pins in complementary pwm mode channel output pin description 3tioca 3 pwm output 1 tiocb 3 pwm output 1' (non-overlapping complementary waveform to pwm output 1) 4tioca 4 pwm output 2 tocxa 4 pwm output 2' (non-overlapping complementary waveform to pwm output 2) tiocb 4 pwm output 3 tocxb 4 pwm output 3' (non-overlapping complementary waveform to pwm output 3) table 8.8 register settings in complementary pwm mode register setting tcnt3 initially specifies the non-overlap margin (difference to tcnt4) tcnt4 initially set to h'0000 gra3 specifies the upper limit value of tcnt3 minus 1 grb3 specifies a transition point of pwm waveforms output from tioca 3 and tiocb 3 gra4 specifies a transition point of pwm waveforms output from tioca 4 and tocxa 4 grb4 specifies a transition point of pwm waveforms output from tiocb 4 and tocxb 4
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 253 of 682 rej09b0353-0300 setup procedure for complementary pwm mode figure 8.33 shows a sample procedure for setting up complementary pwm mode. complementary pwm mode 1. clear bits str3 and str4 to 0 in tstr to halt the timer counters. complementary pwm mode must be set up while tcnt3 and tcnt4 are halted. complementary pwm mode stop counting 1 select counter clock 2 select complementary pwm mode 3 set tcnts 4 set general registers 5 start counters 6 2. set bits tpsc2 to tpsc0 in tcr to select the same counter clock source for channels 3 and 4. if an external clock source is selected, select the external clock edge(s) with bits ckeg1 and ckeg0 in tcr. do not select any counter clear source with bits cclr1 and cclr0 in tcr. 3. set bits cmd1 and cmd0 in tfcr to select complementary pwm mode. tioca 3 , tiocb 3 , tioca 4 , tiocb 4 , tocxa 4 , and tocxb 4 automatically become pwm output pins. 4. clear tcnt4 to h'0000. set the non-overlap margin in tcnt3. do not set tcnt3 and tcnt4 to the same value. 5. gra3 is the waveform period register. set the upper limit value of tcnt3 minus 1 in gra3. set transition times of the pwm output waveforms in grb3, gra4, and grb4. set times within the compare match range of tcnt3 and tcnt4. t x (x: initial setting of grb3, gra4, or grb4. t: initial setting of tcnt3) figure 8.33 setup procedure for complementary pwm mode (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 254 of 682 rej09b0353-0300 clearing complementary pwm mode figure 8.34 shows a sample procedure for clearing complementary pwm mode. complementary pwm mode normal operation clear complementary mode 1 stop counting 2 1. 2. clear bit cmd1 in tfcr to 0, and set channels 3 and 4 to normal operating mode. after setting channels 3 and 4 to normal operating mode, wait at least one clock count before clearing bits str3 and str4 of tstr to 0 to stop the counter operation of tcnt3 and tcnt4. figure 8.34 clearing procedure for complementary pwm mode (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 255 of 682 rej09b0353-0300 examples of complementary pwm mode figure 8.35 shows an example of operation in complementary pwm mode. tcnt3 and tcnt4 operate as up/down-counters, counting down from compare match between tcnt3 and gra3 and counting up from the point at which tcnt4 underflows. during each up-and-down counting cycle, pwm waveforms are generated by compare match with general registers grb3, gra4, and grb4. since tcnt3 is initially set to a higher value than tcnt4, compare match events occur in the sequence tcnt3, tcnt4, tcnt4, tcnt3. tcnt3 and tcnt4 values down-counting starts at compare match between tcnt3 and gra3 time gra3 grb3 gra4 grb4 h'0000 tioca 3 tiocb 3 tioca 4 tocxa 4 tiocb 4 tocxb 4 tcnt3 tcnt4 up-counting starts when tcnt4 underflows figure 8.35 operation in complementary pwm mode (example 1) (when ols3 = ols4 = 1)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 256 of 682 rej09b0353-0300 figure 8.36 shows examples of waveforms with 0 % and 100 % duty cycles (in one phase) in complementary pwm mode. in this example the outputs change at compare match with grb3, so waveforms with duty cycles of 0 % or 100 % can be output by setting grb3 to a value larger than gra3. the duty cycle can be changed easily during operation by use of the buffer registers. for further information see section 8.4.8, buffering. tcnt3 and tcnt4 values time gra3 grb3 tioca 3 tiocb 3 0% duty cycle a. 0% duty cycle tcnt3 and tcnt4 values time gra3 grb3 tioca 3 tiocb 3 100% duty cycle b. 100% duty cycle h'0000 h'0000 figure 8.36 operation in complementary pwm mode (example 2) (when ols3 = ols4 = 1)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 257 of 682 rej09b0353-0300 in complementary pwm mode, tcnt3 and tcnt4 overshoot and undershoot at the transitions between up-counting and down-counting. the setting conditions for the imfa bit in channel 3 and the ovf bit in channel 4 differ from the usual conditions. in buffered operation the buffer transfer conditions also differ. timing diagrams are shown in figures 8.37 and 8.38. tcnt3 gra3 imfa buffer transfer signal (br to gr) gr n e 1 n n + 1 n n e 1 n set to 1 flag not set no buffer transfer buffer transfer figure 8.37 overshoot timing
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 258 of 682 rej09b0353-0300 tcnt4 ovf buffer transfer signal (br to gr) gr h'0001 h'0000 h'ffff h'0000 set to 1 flag not set no buffer transfer buffer transfer underflow overflow figure 8.38 undershoot timing in channel 3, imfa is set to 1 only during up-counting. in channel 4, ovf is set to 1 only when an underflow occurs. when buffering is selected, buffer register contents are transferred to the general register at compare match a3 during up-counting, and when tcnt4 underflows. general register settings in complementary pwm mode when setting up general registers for complementary pwm mode or changing their settings during operation, note the following points. ? initial settings do not set values from h'0000 to t ? 1 (where t is the initial value of tcnt3). after the counters start and the first compare match a3 event has occurred, however, settings in this range also become possible. ? changing settings use the buffer registers. correct waveform output may not be obtained if a general register is written to directly. ? cautions on changes of general register settings figure 8.39 shows six correct examples and one incorrect example.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 259 of 682 rej09b0353-0300 gra3 gr h'0000 br gr not allowed figure 8.39 changing a general register setting by buffer transfer (example 1) ? buffer transfer at transition from up-counting to down-counting if the general register value is in the range from gra3 ? t + 1 to gra3, do not transfer a buffer register value outside this range. conversely, if the general register value is outside this range, do not transfer a value within this range. see figure 8.40. gra3 + 1 gra3 gra3 ? t + 1 gra3 ? t illegal changes tcnt3 tcnt4 figure 8.40 changing a general register setting by buffer transfer (caution 1) ? buffer transfer at transition from down-counting to up-counting if the general register value is in the range from h'0000 to t ? 1, do not transfer a buffer register value outside this range. conversely, when a general register value is outside this range, do not transfer a value within this range. see figure 8.41.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 260 of 682 rej09b0353-0300 t t ? 1 h'0000 h'ffff illegal changes tcnt3 tcnt4 figure 8.41 changing a general register setting by buffer transfer (caution 2) ? general register settings outside the counting range (h'0000 to gra3) waveforms with a duty cycle of 0 % or 100 % can be output by setting a general register to a value outside the counting range. when a buffer register is set to a value outside the counting range, then later restored to a value within the counting range, the counting direction (up or down) must be the same both times. see figure 8.42. 0% duty cycle 100% duty cycle write during down-counting write during up-counting gra3 gr h'0000 output pin output pin br gr figure 8.42 changing a general register setting by buffer transfer (example 2) settings can be made in this way by detecting gra3 compare match or tcnt4 underflow before writing to the buffer register.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 261 of 682 rej09b0353-0300 8.4.7 phase counting mode in phase counting mode the phase difference between two external clock inputs (at the tclka and tclkb pins) is detected, and tcnt2 counts up or down accordingly. in phase counting mode, the tclka and tclkb pins automatically function as external clock input pins and tcnt2 becomes an up/down-counter, regardless of the settings of bits tpsc2 to tpsc0, ckeg1, and ckeg0 in tcr2. settings of bits cclr1, cclr0 in tcr2, and settings in tior2, tier2, tsr2, gra2, and grb2 are valid. the input capture and output compare functions can be used, and interrupts can be generated. phase counting is available only in channel 2. sample setup procedure for phase counting mode figure 8.43 shows a sample procedure for setting up phase counting mode. phase counting mode select phase counting mode select flag setting condition start counter 1 2 3 phase counting mode 1. 2. 3. set the mdf bit in tmdr to 1 to select phase counting mode. select the flag setting condition with the fdir bit in tmdr. set the str2 bit to 1 in tstr to start the timer counter. figure 8.43 setup procedure for phase counting mode (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 262 of 682 rej09b0353-0300 example of phase counting mode figure 8.44 shows an example of operations in phase counting mode. table 8.9 lists the up- counting and down-counting conditions for tcnt2. in phase counting mode both the rising and falling edges of tclka and tclkb are counted. the phase difference between tclka and tclkb must be at least 1.5 states, the phase overlap must also be at least 1.5 states, and the pulse width must be at least 2.5 states. see figure 8.45. tcnt2 value counting up counting down time tclkb tclka figure 8.44 operation in phase counting mode (example) table 8.9 up/down counting conditions counting direction up-counting down-counting tclka pin high low high low tclkb pin low high low high tclka tclkb phase difference phase difference pulse width pulse width overlap overlap phase difference and overlap: pulse width: at least 1.5 states at least 2.5 states figure 8.45 phase difference, overlap, and pulse width in phase counting mode
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 263 of 682 rej09b0353-0300 8.4.8 buffering buffering operates differently depending on whether a general register is an output compare register or an input capture register, with further differences in reset-synchronized pwm mode and complementary pwm mode. buffering is available only in channels 3 and 4. buffering operations under the conditions mentioned above are described next. ? general register used for output compare the buffer register value is transferred to the general register at compare match. see figure 8.46. compare match signal comparator tcnt gr br figure 8.46 compare match buffering ? general register used for input capture the tcnt value is transferred to the general register at input capture. the previous general register value is transferred to the buffer register. see figure 8.47. input capture signal br gr tcnt figure 8.47 input capture buffering ? complementary pwm mode the buffer register value is transferred to the general register when tcnt3 and tcnt4 change counting direction. this occurs at the following two times: ? when tcnt3 matches gra3 ? when tcnt4 underflows ? reset-synchronized pwm mode the buffer register value is transferred to the general register at compare match a3.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 264 of 682 rej09b0353-0300 sample buffering setup procedure figure 8.48 shows a sample buffering setup procedure. buffering select general register functions set buffer bits start counters buffered operation 11. 2. 3. 2 3 set tior to select the output compare or input capture function of the general registers. set bits bfa3, bfa4, bfb3, and bfb4 in tfcr to select buffering of the required general registers. set the str bits to 1 in tstr to start the timer counters. figure 8.48 buffering setup procedure (example) examples of buffering figure 8.49 shows an example in which gra is set to function as an output compare register buffered by bra, tcnt is set to operate as a periodic counter cleared by grb compare match, and tioca and tiocb are set to toggle at compare match a and b. because of the buffer setting, when tioca toggles at compare match a, the bra value is simultaneously transferred to gra. this operation is repeated each time compare match a occurs. figure 8.50 shows the transfer timing.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 265 of 682 rej09b0353-0300 grb h'0250 h'0200 h'0100 h'0000 bra gra tiocb tioca tcnt value counter cleared by compare match b time toggle output toggle output compare match a h'0200 h'0250 h'0100 h'0200 h'0100 h'0200 h'0200 figure 8.49 register buffering (example 1: buffering of output compare register) figure 8.50 compare match and buffer transfer timing (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 266 of 682 rej09b0353-0300 figure 8.51 shows an example in which gra is set to function as an input capture register buffered by bra, and tcnt is cleared by input capture b. the falling edge is selected as the input capture edge at tiocb. both edges are selected as input capture edges at tioca. because of the buffer setting, when the tcnt value is captured into gra at input capture a, the previous gra value is simultaneously transferred to bra. figure 8.52 shows the transfer timing. h'0180 h'0160 h'0005 h'0000 tiocb tioca gra bra grb h'0005 h'0160 h'0005 h'0180 tcnt value counter cleared by input capture b time input capture a h'0160 figure 8.51 register buffering (example 2: buffering of input capture register)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 267 of 682 rej09b0353-0300 figure 8.52 input capture and buffer transfer timing (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 268 of 682 rej09b0353-0300 figure 8.53 shows an example in which grb3 is buffered by brb3 in complementary pwm mode. buffering is used to set grb3 to a higher value than gra3, generating a pwm waveform with 0 % duty cycle. the brb3 value is transferred to grb3 when tcnt3 matches gra3, and when tcnt4 underflows. tcnt3 and tcnt4 values time gra3 h'0999 h'0000 tcnt3 tcnt4 grb3 h'1fff brb3 grb3 tioca 3 tiocb 3 h'0999 h'0999 h'0999 h'1fff h'0999 h'1fff h'1fff h'0999 figure 8.53 register buffering (example 4: buffering in complementary pwm mode)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 269 of 682 rej09b0353-0300 8.4.9 itu output timing the itu outputs from channels 3 and 4 can be disabled by bit settings in toer or by an external trigger, or inverted by bit settings in tocr. timing of enabling and disabling of itu output by toer in this example an itu output is disabled by clearing a master enable bit to 0 in toer. an arbitrary value can be output by appropriate settings of the data register (dr) and data direction register (ddr) of the corresponding input/output port. figure 8.54 illustrates the timing of the enabling and disabling of itu output by toer. figure 8.54 timing of disabling of itu output by writing to toer (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 270 of 682 rej09b0353-0300 timing of disabling of itu output by external trigger if the xtgd bit is cleared to 0 in tocr in reset-synchronized pwm mode or complementary pwm mode, when an input capture a signal occurs in channel 1, the master enable bits are cleared to 0 in toer, disabling itu output. figure 8.55 shows the timing. figure 8.55 timing of disabling of itu output by external trigger (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 271 of 682 rej09b0353-0300 timing of output inversion by tocr the output levels in reset-synchronized pwm mode and complementary pwm mode can be inverted by inverting the output level select bits (ols4 and ols3) in tocr. figure 8.56 shows the timing. figure 8.56 timing of inverting of itu output level by writing to tocr (example)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 272 of 682 rej09b0353-0300 8.5 interrupts the itu has two types of interrupts: input capture/compare match interrupts, and overflow interrupts. 8.5.1 setting of status flags timing of setting of imfa and imfb at compare match imfa and imfb are set to 1 by a compare match signal generated when tcnt matches a general register (gr). the compare match signal is generated in the last state in which the values match (when tcnt is updated from the matching count to the next count). therefore, when tcnt matches a general register, the compare match signal is not generated until the next timer clock input. figure 8.57 shows the timing of the setting of imfa and imfb. figure 8.57 timing of setting of imfa and imfb by compare match
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 273 of 682 rej09b0353-0300 timing of setting of imfa and imfb by input capture imfa and imfb are set to 1 by an input capture signal. the tcnt contents are simultaneously transferred to the corresponding general register. figure 8.58 shows the timing. input capture signal n n figure 8.58 timing of setting of imfa and imfb by input capture timing of setting of overflow flag (ovf) ovf is set to 1 when tcnt overflows from h'ffff to h'0000 or underflows from h'0000 to h'ffff. figure 8.59 shows the timing.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 274 of 682 rej09b0353-0300 overflow signal h'ffff h'0000 figure 8.59 timing of setting of ovf 8.5.2 clearing of status flags if the cpu reads a status flag while it is set to 1, then writes 0 in the status flag, the status flag is cleared. figure 8.60 shows the timing. figure 8.60 timing of clearing of status flags
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 275 of 682 rej09b0353-0300 8.5.3 interrupt sources each itu channel can generate a compare match/input capture a interrupt, a compare match/input capture b interrupt, and an overflow interrupt. in total there are 15 interrupt sources, all independently vectored. an interrupt is requested when the interrupt request flag and interrupt enable bit are both set to 1. the priority order of the channels can be modified in interrupt priority registers a and b (ipra and iprb). for details see section 5, interrupt controller. table 8.10 lists the interrupt sources. table 8.10 itu interrupt sources channel interrupt source description priority * 0imia0 imib0 ovi0 compare match/input capture a0 compare match/input capture b0 overflow 0 high 1imia1 imib1 ovi1 compare match/input capture a1 compare match/input capture b1 overflow 1 2imia2 imib2 ovi2 compare match/input capture a2 compare match/input capture b2 overflow 2 3imia3 imib3 ovi3 compare match/input capture a3 compare match/input capture b3 overflow 3 4imia4 imib4 ovi4 compare match/input capture a4 compare match/input capture b4 overflow 4 low note: * the priority immediately after a reset is indicated. inter-channel priorities can be changed by settings in ipra and iprb.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 276 of 682 rej09b0353-0300 8.6 usage notes this section describes contention and other matters requiring special attention during itu operations. contention between tcnt write and clear if a counter clear signal occurs in the t 3 state of a tcnt write cycle, clearing of the counter takes priority and the write is not performed. see figure 8.61. figure 8.61 contention between tcnt write and clear
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 277 of 682 rej09b0353-0300 contention between tcnt word write and increment if an increment pulse occurs in the t 3 state of a tcnt word write cycle, writing takes priority and tcnt is not incremented. see figure 8.62. figure 8.62 contention between tcnt word write and increment
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 278 of 682 rej09b0353-0300 contention between tcnt byte write and increment if an increment pulse occurs in the t 2 or t 3 state of a tcnt byte write cycle, writing takes priority and tcnt is not incremented. the tcnt byte that was not written retains its previous value. see figure 8.63, which shows an increment pulse occurring in the t 2 state of a byte write to tcnth. figure 8.63 contention between tcnt byte write and increment
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 279 of 682 rej09b0353-0300 contention between general register write and compare match if a compare match occurs in the t 3 state of a general register write cycle, writing takes priority and the compare match signal is inhibited. see figure 8.64. figure 8.64 contention between general register write and compare match
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 280 of 682 rej09b0353-0300 contention between tcnt write and overflow or underflow if an overflow occurs in the t 3 state of a tcnt write cycle, writing takes priority and the counter is not incremented. ovf is set to 1. the same holds for underflow. see figure 8.65. figure 8.65 contention between tcnt write and overflow
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 281 of 682 rej09b0353-0300 contention between general register read and input capture if an input capture signal occurs during the t 3 state of a general register read cycle, the value before input capture is read. see figure 8.66. figure 8.66 contention between general register read and input capture
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 282 of 682 rej09b0353-0300 contention between counter clearing by input capture and counter increment if an input capture signal and counter increment signal occur simultaneously, the counter is cleared according to the input capture signal. the counter is not incremented by the increment signal. the value before the counter is cleared is transferred to the general register. see figure 8.67. figure 8.67 contention between counter clearing by input capture and counter increment
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 283 of 682 rej09b0353-0300 contention between general register write and input capture if an input capture signal occurs in the t 3 state of a general register write cycle, input capture takes priority and the write to the general register is not performed. see figure 8.68. figure 8.68 contention between general register write and input capture note on waveform period setting when a counter is cleared by compare match, the counter is cleared in the last state at which the tcnt value matches the general register value, at the time when this value would normally be updated to the next count. the actual counter frequency is therefore given by the following formula: f = (n + 1) (f: counter frequency. : system clock frequency. n: value set in general register.)
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 284 of 682 rej09b0353-0300 contention between buffer register write and input capture if a buffer register is used for input capture buffering and an input capture signal occurs in the t 3 state of a write cycle, input capture takes priority and the write to the buffer register is not performed. see figure 8.69. figure 8.69 contention between buffer register write and input capture
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 285 of 682 rej09b0353-0300 note on synchronous preset when channels are synchronized, if a tcnt value is modified by byte write access, all 16 bits of all synchronized counters assume the same value as the counter that was addressed. (example) when channels 2 and 3 are synchronized  byte write to channel 2 or byte write to channel 3 tcnt2 tcnt3 w y x z tcnt2 tcnt3 a a x x tcnt2 tcnt3 y y a a tcnt2 tcnt3 w y x z tcnt2 tcnt3 a a b b  word write to channel 2 or word write to channel 3 upper byte lower byte upper byte lower byte upper byte lower byte upper byte lower byte upper byte lower byte write a to upper byte of channel 2 write a to lower byte of channel 3 write ab word to channel 2 or 3 note on setup of reset-synchronized pwm mode and complementary pwm mode when setting bits cmd1 and cmd0 in tfcr, take the following precautions: ? write to bits cmd1 and cmd0 only when tcnt3 and tcnt4 are stopped. ? do not switch directly between reset-synchronized pwm mode and complementary pwm mode. first switch to normal mode (by clearing bit cmd1 to 0), then select reset-synchronized pwm mode or complementary pwm mode.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 286 of 682 rej09b0353-0300 itu operating modes table 8.11 (a) itu operating modes (channel 0) register settings tsnc tmdr tfcr tocr toer tior0 tcr0 reset- synchro- nized pwm comple- mentary pwm output level select synchro- nization buffer- ing master enable clear select clock select operating mode mdf fdir pwm xtgd ioa iob synchronous preset sync0 = 1 ?? ? ? ??? ? pwm mode ?? pwm0 = 1 ? ? ??? ? ? * output compare a ?? pwm0 = 0 ? ? ??? ? ioa2 = 0 other bits unrestricted output compare b ?? ? ? ??? ? iob2 = 0 other bits unrestricted input capture a ?? pwm0 = 0 ? ? ??? ? ioa2 = 1 other bits unrestricted input capture b ?? pwm0 = 0 ? ? ??? ? iob2 = 1 other bits unrestricted counter by compare ?? ? ? ??? ? cclr1 = 0 clearing match/input cclr0 = 1 capture a by compare ?? ? ? ??? ? cclr1 = 1 match/input cclr0 = 0 capture b syn- sync0 = 1 ?? ? ? ??? ? cclr1 = 1 chronous cclr0 = 1 clear legend: : setting available (valid). ? : setting does not affect this mode. note: the input capture function cannot be used in pwm mode. if compare match a and compare match b occur simultaneously, the compare match signal is inhibited.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 287 of 682 rej09b0353-0300 table 8.11 (b) itu operating modes (channel 1) register settings tsnc tmdr tfcr tocr toer tior1 tcr1 reset- synchro- nized pwm comple- mentary pwm output level select synchro- nization buffer- ing master enable clear select clock select operating mode mdf fdir pwm xtgd ioa iob synchronous preset sync1 = 1 ?? ? ? ?? ? ? pwm mode ?? pwm1 = 1 ?????? ? * 1 output compare a ?? pwm1 = 0 ?????? ioa2 = 0 other bits unrestricted output compare b ?? ? ? ?? ? ? iob2 = 0 other bits unrestricted input capture a ?? pwm1 = 0 ??? * 2 ?? ioa2 = 1 other bits unrestricted input capture b ?? pwm1 = 0 ?????? iob2 = 1 other bits unrestricted counter by compare ?? ? ? ?? ? ? cclr1 = 0 clearing match/input cclr0 = 1 capture a by compare ?? ? ? ?? ? ? cclr1 = 1 match/input cclr0 = 0 capture b syn- sync1 = 1 ?? ? ? ?? ? ? cclr1 = 1 chronous cclr0 = 1 clear legend: : setting available (valid). ? : setting does not affect this mode. notes: 1. the input capture function cannot be used in pwm mode. if compare match a and compare match b occur simultaneously, the compare match signal is inhibited. 2. valid only when channels 3 and 4 are operating in complementary pwm mode or reset-synchronized pwm mode.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 288 of 682 rej09b0353-0300 table 8.11 (c) itu operating modes (channel 2) register settings tsnc tmdr tfcr tocr toer tior2 tcr2 reset- synchro- nized pwm comple- mentary pwm output level select synchro- nization buffer- ing master enable clear select clock select operating mode mdf fdir pwm xtgd ioa iob synchronous preset sync2 = 1 ??????? pwm mode ? pwm2 = 1 ??????? * output compare a ? pwm2 = 0 ?????? ioa2 = 0 other bits unrestricted output compare b ??????? iob2 = 0 other bits unrestricted input capture a ? pwm2 = 0 ?????? ioa2 = 1 other bits unrestricted input capture b ? pwm2 = 0 ?????? iob2 = 1 other bits unrestricted counter by compare ??????? cclr1 = 0 clearing match/input cclr0 = 1 capture a by compare ??????? cclr1 = 1 match/input cclr0 = 0 capture b syn- sync2 = 1 ??????? cclr1 = 1 chronous cclr0 = 1 clear phase counting mdf = 1 ?????? ? mode legend: : setting available (valid). ? : setting does not affect this mode. note: the input capture function cannot be used in pwm mode. if compare match a and compare match b occur simultaneously , the compare match signal is inhibited.
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 289 of 682 rej09b0353-0300 table 8.11 (d) itu operating modes (channel 3) register settings tsnc tmdr tfcr tocr toer tior3 tcr3 comple- mentary pwm reset- synchro- nized pwm output level select synchro- nization master enable clear select clock select operating mode mdf fdir pwm buffering xtgd ioa iob synchronous preset sync3 = 1 ?? ?? pwm mode ?? pwm3 = 1 cmd1 = 0 cmd1 = 0 ?? ? output compare a ?? pwm3 = 0 cmd1 = 0 cmd1 = 0 ?? ioa2 = 0 other bits unrestricted output compare b ?? cmd1 = 0 cmd1 = 0 ?? iob2 = 0 other bits unrestricted input capture a ?? pwm3 = 0 cmd1 = 0 cmd1 = 0 ?? ea3 ignored ioa2 = 1 other bits other bits unrestricted unrestricted input capture b ?? pwm3 = 0 cmd1 = 0 cmd1 = 0 ?? eb3 ignored iob2 = 1 other bits other bits unrestricted unrestricted counter by compare ?? illegal setting: ?? cclr1 = 0 clearing match/input cmd1 = 1 cclr0 = 1 capture a cmd0 = 0 by compare ?? cmd1 = 0 cmd1 = 0 ?? cclr1 = 1 match/input cclr0 = 0 capture b syn- sync3 = 1 ?? illegal setting: ?? cclr1 = 1 chronous cmd1 = 1 cclr0 = 1 clear cmd0 = 0 complementary ?? ? cmd1 = 1 cmd1 = 1 ?? cclr1 = 0 * 5 pwm mode cmd0 = 0 cmd0 = 0 cclr0 = 0 reset-synchronized ?? ? cmd1 = 1 cmd1 = 1 ?? cclr1 = 0 pwm mode cmd0 = 1 cmd0 = 1 cclr0 = 1 buf fering ?? bfa3 = 1 ?? (bra) other bits unrestricted buffering ?? bfb3 = 1 ?? (brb) other bits unrestricted legend: : setting available (valid). ? : setting does not affect this mode. notes: 1. master enable bit settings are valid only during waveform output. 2. the input capture function cannot be used in pwm mode. if compare match a and compare match b occur simultaneously, the compa re match signal is inhibited. 3. do not set both channels 3 and 4 for synchronous operation when complementary pwm mode is selected. 4. the counter cannot be cleared by input capture a when reset-synchronized pwm mode is selected. 5. in complementary pwm mode, select the same clock source for channels 3 and 4. 6. use the input capture a function in channel 1. * 2 * 1 * 1 * 1 * 1 * 1 * 1 * 6 * 6 * 4 * 3 * 3
section 8 16-bit integrated timer unit (itu) rev.3.00 mar. 26, 2007 page 290 of 682 rej09b0353-0300 table 8.11 (e) itu operating modes (channel 4) register settings tsnc tmdr tfcr tocr toer tior4 tcr4 comple- mentary pwm reset- synchro- nized pwm output level select synchro- nization master enable clear select clock select operating mode mdf fdir pwm buffering xtgd ioa iob synchronous preset sync4 = 1 ?? ?? pwm mode ?? pwm4 = 1 cmd1 = 0 cmd1 = 0 ?? ? output compare a ?? pwm4 = 0 cmd1 = 0 cmd1 = 0 ?? ioa2 = 0 other bits unrestricted output compare b ?? cmd1 = 0 cmd1 = 0 ?? iob2 = 0 other bits unrestricted input capture a ?? pwm4 = 0 cmd1 = 0 cmd1 = 0 ?? ea4 ignored ioa2 = 1 other bits other bits unrestricted unrestricted input capture b ?? pwm4 = 0 cmd1 = 0 cmd1 = 0 ?? eb4 ignored iob2 = 1 other bits other bits unrestricted unrestricted counter by compare ?? illegal setting: ?? cclr1 = 0 clearing match/input cmd1 = 1 cclr0 = 1 capture a cmd0 = 0 by compare ?? illegal setting: ?? cclr1 = 1 match/input cmd1 = 1 cclr0 = 0 capture b cmd0 = 0 syn- sync4 = 1 ?? illegal setting: ?? cclr1 = 1 chronous cmd1 = 1 cclr0 = 1 clear cmd0 = 0 complementary ?? ? cmd1 = 1 cmd1 = 1 ?? cclr1 = 0 pwm mode cmd0 = 0 cmd0 = 0 cclr0 = 0 reset-synchronized ?? ? cmd1 = 1 cmd1 = 1 ?? * 6 * 6 * 5 pwm mode cmd0 = 1 cmd0 = 1 buffering ?? bfa4 = 1 ?? (bra) other bits unrestricted buffering ?? bfb4 = 1 ?? (brb) other bits unrestricted legend: : setting available (valid). ? : setting does not affect this mode. notes: 1. master enable bit settings are valid only during waveform output. 2. the input capture function cannot be used in pwm mode. if compare match a and compare match b occur simultaneously, the compa re match signal is inhibited. 3. do not set both channels 3 and 4 for synchronous operation when complementary pwm mode is selected. 4. when reset-synchronized pwm mode is selected, tcnt4 operates independently and the counter clearing function is available. w a veform output is not affected. 5. in complementary pwm mode, select the same clock source for channels 3 and 4. 6. tcr4 settings are valid in reset-synchronized pwm mode, but tcnt4 operates independently , without affecting waveform output. * 2 * 1 * 1 * 4 * 4 * 4 * 3 * 3 * 1 * 1 * 1 * 1
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 291 of 682 rej09b0353-0300 section 9 programmable timing pattern controller 9.1 overview the h8/3039 group has a built-in programmable timing pattern controller (tpc)* that provides pulse outputs by using the 16-bit integrated timer-pulse unit (itu) as a time base. the tpc pulse outputs are divided into 4-bit groups (group 3 to group 0) that can operate simultaneously and independently. 9.1.1 features tpc features are listed below. ? 15-bit output data maximum 15-bit data can be output. tpc output can be enabled on a bit-by-bit basis. ? four output groups and one 3-bit output. output trigger signals can be selected in 4-bit groups to provide up to three different 4-bit outputs and one 3-bit output. ? selectable output trigger signals output trigger signals can be selected for each group from the compare-match signals of four itu channels. ? non-overlap mode a non-overlap margin can be provided between pulse outputs. note: * note that since this lsi does not have a tp 14 pin, it is a 15-bit programmable timing pattern controller (tpc).
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 292 of 682 rej09b0353-0300 9.1.2 block diagram figure 9.1 shows a block diagram of the tpc. paddr ndera tpmr pbddr nderb tpcr internal data bus tp tp tp tp tp tp tp tp tp tp tp tp tp tp tp tp 15 14 13 12 11 10 control logic itu compare match signals pulse output pins, group 3 pbdr padr legend: tpmr: tpcr: nderb: ndera: pbddr: paddr: ndrb: ndra: pbdr: padr: pulse output pins, group 2 pulse output pins, group 1 pulse output pins, group 0 tpc output mode register tpc output control register next data enable register b next data enable register a port b data direction register port a data direction register next data register b next data register a port b data register port a data register ndrb ndra ( ) * note: * since this lsi does not have this pin, this signal cannot be output to the outside. 9 8 7 6 5 4 3 2 1 0 figure 9.1 tpc block diagram
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 293 of 682 rej09b0353-0300 9.1.3 tpc pins table 9.1 summarizes the tpc output pins. table 9.1 tpc pins name symbol i/o function tpc output 0 tp 0 output group 0 pulse output tpc output 1 tp 1 output tpc output 2 tp 2 output tpc output 3 tp 3 output tpc output 4 tp 4 output group 1 pulse output tpc output 5 tp 5 output tpc output 6 tp 6 output tpc output 7 tp 7 output tpc output 8 tp 8 output group 2 pulse output tpc output 9 tp 9 output tpc output 10 tp 10 output tpc output 11 tp 11 output tpc output 12 tp 12 output group 3 pulse output tpc output 13 tp 13 output (tpc output 14) * (tp 14 ) * (output) * tpc output 15 tp 15 output note: * since this lsi does not have this pin, this signal cannot be output to the outside.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 294 of 682 rej09b0353-0300 9.1.4 registers table 9.2 summarizes the tpc registers. table 9.2 tpc registers address * 1 name abbreviation r/w initial value h'ffd1 port a data direction register paddr w h'00 h'ffd3 port a data register padr r/(w) * 2 h'00 h'ffd4 port b data direction register pbddr w h'00 h'ffd6 port b data register pbdr r/(w) * 2 h'00 h'ffa0 tpc output mode register tpmr r/w h'f0 h'ffa1 tpc output control register tpcr r/w h'ff h'ffa2 next data enable register b nderb r/w h'00 h'ffa3 next data enable register a ndera r/w h'00 h'ffa5/ h'ffa7 * 3 next data register a ndra r/w h'00 h'ffa4/ h'ffa6 * 3 next data register b ndrb r/w h'00 notes: 1. lower 16 bits of the address. 2. bits used for tpc output cannot be written. 3. the ndra address is h'ffa5 when the same output trigger is selected for tpc output groups 0 and 1 by settings in tpcr. when the output triggers are different, the ndra address is h'ffa7 for group 0 and h'ffa5 for group 1. similarly, the address of ndrb is h'ffa4 when the same output trigger is selected for tpc output groups 2 and 3 by settings in tpcr. when the output triggers are different, the ndrb address is h'ffa6 for group 2 and h'ffa4 for group 3.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 295 of 682 rej09b0353-0300 9.2 register descriptions 9.2.1 port a data direction register (paddr) paddr is an 8-bit write-only register that selects input or output for each pin in port a. bit initial value read/write 7 pa ddr 0 w port a data direction 7 to 0 these bits select input or output for port a pins 7 6 pa ddr 0 w 6 5 pa ddr 0 w 5 4 pa ddr 0 w 4 3 pa ddr 0 w 3 2 pa ddr 0 w 2 1 pa ddr 0 w 1 0 pa ddr 0 w 0 port a is multiplexed with pins tp 7 to tp 0 . bits corresponding to pins used for tpc output must be set to 1. for further information about paddr, see section 7.10, port a. 9.2.2 port a data register (padr) padr is an 8-bit readable/writable register that stores tpc output data for groups 0 and 1, when these tpc output groups are used. bit initial value read/write note: * bits selected for tpc output by ndera settings become read-only bits. 0 pa 0 r/(w) 0 1 pa 0 r/(w) 1 2 pa 0 r/(w) 2 3 pa 0 r/(w) 3 4 pa 0 r/(w) 4 5 pa 0 r/(w) 5 6 pa 0 r/(w) 6 7 pa 0 r/(w) 7 port a data 7 to 0 these bits store output data for tpc output groups 0 and 1 ******** for further information about padr, see section 7.10, port a.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 296 of 682 rej09b0353-0300 9.2.3 port b data direction register (pbddr) pbddr is an 8-bit write-only register that selects input or output for each pin in port b. bit initial value read/write 7 pb ddr 0 w port b data direction 7, 5 to 0 these bits select input or output for port b pins 7 6 ? 0 w 5 pb ddr 0 w 5 4 pb ddr 0 w 4 3 pb ddr 0 w 3 2 pb ddr 0 w 2 1 pb ddr 0 w 1 0 pb ddr 0 w 0 reserved bit port b is multiplexed with pins tp 15 , tp 13 to tp 8 . bits corresponding to pins used for tpc output must be set to 1. for further information about pbddr, see section 7.11, port b. 9.2.4 port b data register (pbdr) pbdr is an 8-bit readable/writable register that stores tpc output data for groups 2 and 3, when these tpc output groups are used. bit initial value read/write note: * bits selected for tpc output by nderb settings become read-only bits. 0 pb 0 r/(w) 0 1 pb 0 r/(w) 1 2 pb 0 r/(w) 2 3 pb 0 r/(w) 3 4 pb 0 r/(w) 4 5 pb 0 r/(w) 5 6 ? 0 r/(w) 7 pb 0 r/(w) 7 port b data 7, 5 to 0 these bits store output data for tpc output groups 2 and 3 ******** reserved bit for further information about pbdr, see section 7.11, port b.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 297 of 682 rej09b0353-0300 9.2.5 next data register a (ndra) ndra is an 8-bit readable/writable register that stores the next output data for tpc output groups 1 and 0 (pins tp 7 to tp 0 ). during tpc output, when an itu compare match event specified in tpcr occurs, ndra contents are transferred to the corresponding bits in padr. the address of ndra differs depending on whether tpc output groups 0 and 1 have the same output trigger or different output triggers. ndra is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. same trigger for tpc output groups 0 and 1 if tpc output groups 0 and 1 are triggered by the same compare match event, the ndra address is h'ffa5. the upper 4 bits belong to group 1 and the lower 4 bits to group 0. address h'ffa7 consists entirely of reserved bits that cannot be modified and always read 1. address h'ffa5 bit initial value read/write 7 ndr7 0 r/w 6 ndr6 0 r/w 5 ndr5 0 r/w 4 ndr4 0 r/w 3 ndr3 0 r/w 2 ndr2 0 r/w 1 ndr1 0 r/w 0 ndr0 0 r/w next data 3 to 0 these bits store the next output data for tpc output group 0 next data 7 to 4 these bits store the next output data for tpc output group 1 address h'ffa7 bit initial value read/write 0 ? 1 ? 1 ? 1 ? 2 ? 1 ? 3 ? 1 ? 4 ? 1 ? 5 ? 1 ? 6 ? 1 ? 7 ? 1 ? reserved bits
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 298 of 682 rej09b0353-0300 different triggers for tpc output groups 0 and 1 if tpc output groups 0 and 1 are triggered by different compare match events, the address of the upper 4 bits of ndra (group 1) is h'ffa5 and the address of the lower 4 bits (group 0) is h'ffa7. bits 3 to 0 of address h'ffa5 and bits 7 to 4 of address h'ffa7 are reserved bits that cannot be modified and always read 1. address h'ffa5 bit initial value read/write 7 ndr7 0 r/w 6 ndr6 0 r/w 5 ndr5 0 r/w 4 ndr4 0 r/w 3 ? 1 ? 2 ? 1 ? 1 ? 1 ? 0 ? 1 ? reserved bits next data 7 to 4 these bits store the next output data for tpc output group 1 address h'ffa7 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ndr3 0 r/w 2 ndr2 0 r/w 1 ndr1 0 r/w 0 ndr0 0 r/w next data 3 to 0 these bits store the next output data for tpc output group 0 reserved bits
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 299 of 682 rej09b0353-0300 9.2.6 next data register b (ndrb) ndrb is an 8-bit readable/writable register that stores the next output data for tpc output groups 3 and 2 (pins tp 15 to tp 8 )*. during tpc output, when an itu compare match event specified in tpcr occurs, ndrb contents are transferred to the corresponding bits in pbdr. the address of ndrb differs depending on whether tpc output groups 2 and 3 have the same output trigger or different output triggers. ndrb is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output to the outside. same trigger for tpc output groups 2 and 3 if tpc output groups 2 and 3 are triggered by the same compare match event, the ndrb address is h'ffa4. the upper 4 bits belong to group 3 and the lower 4 bits to group 2. address h'ffa6 consists entirely of reserved bits that cannot be modified and always read 1. address h'ffa4 bit initial value read/write 7 ndr15 0 r/w 6 ndr14 0 r/w 5 ndr13 0 r/w 4 ndr12 0 r/w 3 ndr11 0 r/w 2 ndr10 0 r/w 1 ndr9 0 r/w 0 ndr8 0 r/w next data 11 to 8 these bits store the next output data for tpc output group 2 next data 15 to 12 these bits store the next output data for tpc output group 3 address h'ffa6 bit initial value read/write 0 ? 1 ? 1 ? 1 ? 2 ? 1 ? 3 ? 1 ? 4 ? 1 ? 5 ? 1 ? 6 ? 1 ? 7 ? 1 ? reserved bits
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 300 of 682 rej09b0353-0300 different triggers for tpc output groups 2 and 3 if tpc output groups 2 and 3 are triggered by different compare match events, the address of the upper 4 bits of ndrb (group 3)* is h'ffa4 and the address of the lower 4 bits (group 2) is h'ffa6. bits 3 to 0 of address h'ffa4 and bits 7 to 4 of address h'ffa6 are reserved bits that cannot be modified and always read 1. note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip. address h'ffa4 bit initial value read/write 7 ndr15 0 r/w 6 ndr14 0 r/w 5 ndr13 0 r/w 4 ndr12 0 r/w 3 ? 1 ? 2 ? 1 ? 1 ? 1 ? 0 ? 1 ? reserved bits next data 15 to 12 these bits store the next output data for tpc output group 3 address h'ffa6 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ndr11 0 r/w 2 ndr10 0 r/w 1 ndr9 0 r/w 0 ndr8 0 r/w next data 11 to 8 these bits store the next output data for tpc output group 2 reserved bits
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 301 of 682 rej09b0353-0300 9.2.7 next data enable register a (ndera) ndera is an 8-bit readable/writable register that enables or disables tpc output groups 1 and 0 (tp 7 to tp 0 ) on a bit-by-bit basis. bit initial value read/write 0 nder0 0 r/w 1 nder1 0 r/w 2 nder2 0 r/w 3 nder3 0 r/w 4 nder4 0 r/w 5 nder5 0 r/w 6 nder6 0 r/w 7 nder7 0 r/w next data enable 7 to 0 these bits enable or disable tpc output groups 1 and 0 if a bit is enabled for tpc output by ndera, then when the itu compare match event selected in the tpc output control register (tpcr) occurs, the ndra value is automatically transferred to the corresponding padr bit, updating the output value. if tpc output is disabled, the bit value is not transferred from ndra to padr and the output value does not change. ndera is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 0?next data enable 7 to 0 (nder7 to nder0): these bits enable or disable tpc output groups 1 and 0 (tp 7 to tp 0 ) on a bit-by-bit basis. bits 7 to 0 nder7 to nder0 description 0 tpc outputs tp 7 to tp 0 are disabled (ndr 7 to ndr0 are not transferred to pa 7 to pa 0 ) (initial value) 1 tpc outputs tp 7 to tp 0 are enabled (ndr 7 to ndr 0 are transferred to pa 7 to pa 0 )
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 302 of 682 rej09b0353-0300 9.2.8 next data enable register b (nderb) nderb is an 8-bit readable/writable register that enables or disables tpc output groups 3 and 2 (tp 15 to tp 8 )* on a bit-by-bit basis. bit initial value read/write 0 nder8 0 r/w 1 nder9 0 r/w 2 nder10 0 r/w 3 nder11 0 r/w 4 nder12 0 r/w 5 nder13 0 r/w 6 nder14 0 r/w 7 nder15 0 r/w next data enable 15 to 8 these bits enable or disable tpc output groups 3 and 2 if a bit is enabled for tpc output by nderb, then when the itu compare match event selected in the tpc output control register (tpcr) occurs, the ndrb value is automatically transferred to the corresponding pbdr bit, updating the output value. if tpc output is disabled, the bit value is not transferred from ndrb to pbdr and the output value does not change. nderb is initialized to h'00 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 0?next data enable 15 to 8 (nder15 to nder8): these bits enable or disable tpc output groups 3 and 2 (tp 15 to tp 8 )* on a bit-by-bit basis. bits 7 to 0 nder15 to nder8 description 0 tpc outputs tp 15 to tp 8 are disabled (ndr15 to ndr8 are not transferred to pb 7 to pb 0 ) (initial value) 1 tpc outputs tp 15 to tp 8 are enabled (ndr15 to ndr8 are transferred to pb 7 to pb 0 ) note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output to the outside.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 303 of 682 rej09b0353-0300 9.2.9 tpc output control register (tpcr) tpcr is an 8-bit readable/writable register that selects output trigger signals for tpc outputs on a group-by-group basis. bit initial value read/write 7 g3cms1 1 r/w 6 g3cms0 1 r/w 5 g2cms1 1 r/w 4 g2cms0 1 r/w 3 g1cms1 1 r/w 0 g0cms0 1 r/w 2 g1cms0 1 r/w 1 g0cms1 1 r/w group 3 compare match select 1 and 0 these bits select the compare match event that triggers tpc output group 3 (tp 15 to tp 12 ) * group 2 compare match select 1 and 0 these bits select the compare match event that triggers tpc output group 2 (tp 11 to tp 8 ) group 1 compare match select 1 and 0 these bits select the compare match event that triggers tpc output group 1 (tp 7 to tp 4 ) group 0 compare match select 1 and 0 these bits select the compare match event that triggers tpc output group 0 (tp 3 to tp 0 ) note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output to the outside. tpcr is initialized to h'ff by a reset and in hardware standby mode. it is not initialized in software standby mode.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 304 of 682 rej09b0353-0300 bits 7 and 6?group 3 compare match select 1 and 0 (g3cms1, g3cms0): these bits select the compare match event that triggers tpc output group 3 (tp 15 to tp 12 )*. bit 7 g3cms1 bit6 g3cms0 description 0 0 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 0 1 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 1 1 0 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 2 1 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 3 (initial value) note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip. bits 5 and 4?group 2 compare match select 1 and 0 (g2cms1, g2cms0): these bits select the compare match event that triggers tpc output group 2 (tp 11 to tp 8 ). bit 5 g2cms1 bit4 g2cms0 description 0 0 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 0 1 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 1 1 0 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 2 1 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 3 (initial value)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 305 of 682 rej09b0353-0300 bits 3 and 2?group 1 compare match select 1 and 0 (g1cms1, g1cms0): these bits select the compare match event that triggers tpc output group 1 (tp 7 to tp 4 ). bit 3 g1cms1 bit2 g1cms0 description 0 0 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 0 1 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 1 1 0 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 2 1 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 3 (initial value) bits 1 and 0?group 0 compare match select 1 and 0 (g0cms1, g0cms0): these bits select the compare match event that triggers tpc output group 0 (tp 3 to tp 0 ). bit1 g0cms1 bit0 g0cms0 description 0 0 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 0 1 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 1 1 0 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 2 1 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 3 (initial value)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 306 of 682 rej09b0353-0300 9.2.10 tpc output mode register (tpmr) tpmr is an 8-bit readable/writable register that selects normal or non-overlapping tpc output for each group. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 g3nov 0 r/w 0 g0nov 0 r/w 2 g2nov 0 r/w 1 g1nov 0 r/w group 3 non-overlap selects non-overlapping tpc output for group 3 (tp to tp ) * reserved bits group 2 non-overlap selects non-overlapping tpc output for group 2 (tp to tp ) group 1 non-overlap selects non-overlapping tpc output for group 1 (tp to tp ) group 0 non-overlap selects non-overlapping tpc output for group 0 (tp to tp ) 15 12 11 8 74 30 note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output to the outside. the output trigger period of a non-overlapping tpc output waveform is set in general register b (grb) in the itu channel selected for output triggering. the non-overlap margin is set in general register a (gra). the output values change at compare match a and b. for details see section 9.3.4, non-overlapping tpc output. tpmr is initialized to h'f0 by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 4?reserved: these bits cannot be modified and are always read as 1.
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 307 of 682 rej09b0353-0300 bit 3?group 3 non-overlap (g3nov): selects normal or non-overlapping tpc output for group 3 (tp 15 to tp 12 )*. note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip. bit 3 g3nov description 0 normal tpc output in group 3 (output values change at compare match a in the selected itu channel) (initial value) 1 non-overlapping tpc output in group 3 (independent 1 and 0 output at compare match a and b in the selected itu channel) bit 2?group 2 non-overlap (g2nov): selects normal or non-overlapping tpc output for group 2 (tp 11 to tp 8 ). bit 2 g2nov description 0 normal tpc output in group 2 (output values change at compare match a in the selected itu channel) (initial value) 1 non-overlapping tpc output in group 2 (independent 1 and 0 output at compare match a and b in the selected itu channel) bit 1?group 1 non-overlap (g1nov): selects normal or non-overlapping tpc output for group 1 (tp 7 to tp 4 ). bit 1 g1nov description 0 normal tpc output in group 1 (output values change at compare match a in the selected itu channel) (initial value) 1 non-overlapping tpc output in group 1 (independent 1 and 0 output at compare match a and b in the selected itu channel)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 308 of 682 rej09b0353-0300 bit 0?group 0 non-overlap (g0nov): selects normal or non-overlapping tpc output for group 0 (tp 3 to tp 0 ). bit 0 g0nov description 0 normal tpc output in group 0 (output values change at compare match a in the selected itu channel) (initial value) 1 non-overlapping tpc output in group 0 (independent 1 and 0 output at compare match a and b in the selected itu channel) 9.3 operation 9.3.1 overview when corresponding bits in paddr or pbddr and ndera or nderb are set to 1, tpc output is enabled. the tpc output initially consists of the corresponding padr or pbdr contents. when a compare-match event selected in tpcr occurs, the corresponding ndra or ndrb bit contents are transferred to padr or pbdr to update the output values. figure 9.2 illustrates the tpc output operation. table 9.3 summarizes the tpc operating conditions. ddr nder qq tpc output pin dr ndr c qd qd internal data bus output trigger signal figure 9.2 tpc output operation
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 309 of 682 rej09b0353-0300 table 9.3 tpc operating conditions nder ddr pin function 0 0 generic input port 1 generic output port 1 0 generic input port (but the dr bit is a read-only bit, and when compare match occurs, the ndr bit value is transferred to the dr bit) 1 tpc pulse output sequential output of up to 16-bit patterns is possible by writing new output data to ndra and ndrb before the next compare match. for information on non-overlapping operation, see section 9.3.4, non-overlapping tpc output. 9.3.2 output timing if tpc output is enabled, ndra/ndrb contents are transferred to padr/pbdr and output when the selected compare match event occurs. figure 9.3 shows the timing of these operations for the case of normal output in groups 0 and 1, triggered by compare match a. figure 9.3 timing of transfer of next data register contents and output (example)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 310 of 682 rej09b0353-0300 9.3.3 normal tpc output sample setup procedure for normal tpc output figure 9.4 shows a sample procedure for setting up normal tpc output. normal tpc output set next tpc output data compare match? no yes set next tpc output data itu setup port and tpc setup itu setup 10 11 9 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. set tior to make gra an output compare register (with output inhibited). set the tpc output trigger period. select the counter clock source with bits tpsc2 to tpsc0 in tcr. select the counter clear source with bits cclr1 and cclr0. enable the imfa interrupt in tier. set the initial output values in the dr bits of the input/output port pins to be used for tpc output. set the ddr bits of the input/output port pins to be used for tpc output to 1. set the nder bits of the pins to be used for tpc output to 1. select the itu compare match event to be used as the tpc output trigger in tpcr. set the next tpc output values in the ndr bits. set the str bit to 1 in tstr to start the timer counter. at each imfa interrupt, set the next output values in the ndr bits. 1 2 3 4 5 6 7 8 select gr functions set gra value select counting operation select interrupt request start counter set initial output data select port output enable tpc output select tpc output trigger figure 9.4 setup procedure for normal tpc output (example)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 311 of 682 rej09b0353-0300 example of normal tpc output (example of five-phase pulse output) figure 9.5 shows an example in which the tpc is used for cyclic five-phase pulse output. gra h'0000 ndra padr tp 7 tp 6 tp 5 tp 4 tp 3     time 80 tcnt tcnt value c0 40 60 20 30 10 18 08 88 80 c0 compare match the itu channel to be used as the output trigger channel is set up so that gra is an output compare register and the counter will be cleared by compare match a. the trigger period is set in gra. the imiea bit is set to 1 in tier to enable the compare match a interrupt. h'f8 is written in paddr and ndera, and bits g1cms1, g1cms0, g0cms1, and g0cms0 are set in tpcr to select compare match in the itu channel set up in step 1 as the output trigger. output data h'80 is written in ndra. the timer counter in this itu channel is started. when compare match a occurs, the ndra contents are transferred to padr and output. the compare match/input capture a (imfa) interrupt service routine writes the next output data (h'c0) in ndra. five-phase overlapping pulse output (one or two phases active at a time) can be obtained by writing h'40, h'60, h'20, h'30, h'10, h'18, h'08, h'88... at successive imfa interrupts. 00 80 c0 40 60 20 30 10 18 08 88 80 c0 40 figure 9.5 normal tpc output example (five-phase pulse output)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 312 of 682 rej09b0353-0300 9.3.4 non-overlapping tpc output sample setup procedure for non-overlapping tpc output figure 9.6 shows a sample procedure for setting up non-overlapping tpc output. non-overlapping tpc output set next tpc output data compare match a? no yes set next tpc output data start counter itu setup port and tpc setup itu setup set initial output data set up tpc output enable tpc transfer select tpc transfer trigger select non-overlapping groups 1 2 3 4 12 10 11 5 6 7 8 9 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. set tior to make gra and grb output compare registers (with output inhibited). set the tpc output trigger period in grb and the non-overlap margin in gra. select the counter clock source with bits tpsc2 to tpsc0 in tcr. select the counter clear source with bits cclr1 and cclr0. enable the imfa interrupt in tier. set the initial output values in the dr bits of the input/output port pins to be used for tpc output. set the ddr bits of the input/output port pins to be used for tpc output to 1. set the nder bits of the pins to be used for tpc output to 1. in tpcr, select the itu compare match event to be used as the tpc output trigger. in tpmr, select the groups that will operate in non-overlap mode. set the next tpc output values in the ndr bits. set the str bit to 1 in tstr to start the timer counter. at each imfa interrupt, write the next output value in the ndr bits. select gr functions set gr values select counting operation select interrupt requests figure 9.6 setup procedure for non-overlapping tpc output (example)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 313 of 682 rej09b0353-0300 example of non-overlapping tpc output (example of four-phase complementary non-overlapping output) figure 9.7 shows an example of the use of tpc output for four-phase complementary non- overlapping pulse output. grb h'0000 ndra padr tp 7 tp 6 tp 5 tp 4 tp 3 tp 2 tp 1 tp 0 time 95 00 65 95 59 56 95 65 05 65 41 59 50 56 14 95 05 65 tcnt period is set in grb. the non-overlap margin is set in gra. the imiea bit is set to 1 in tier to enable imfa interrupts. h'ff is written in paddr and ndera, and bits g1cms1, g1cms0, g0cms1, and g0cms0 are set in tpcr to select compare match in the itu channel set up in step 1 as the output trigger. tcnt value non-overlap margin the itu channel to be used as the output trigger channel is set up so that gra and grb are output compare registers and the counter will be cleared by compare match b. the tpc output trigger     bits g1nov and g0nov are set to 1 in tpmr to select non-overlapping output. output data h'95 is written in ndra. the timer counter in this itu channel is started. when compare match b occurs, outputs change from 1 to 0. when compare match a occurs, outputs change from 0 to 1 (the change from 0 to 1 is delayed by the value of gra). the imfa interrupt service routine writes the next output data (h'65) in ndra. four-phase complementary non-overlapping pulse output can be obtained by writing h'59, h'56, h'95... at successive imfa interrupts. gra figure 9.7 non-overlapping tpc output example (four-phase complementary non-overlapping pulse output)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 314 of 682 rej09b0353-0300 9.3.5 tpc output triggering by input capture tpc output can be triggered by itu input capture as well as by compare match. if gra functions as an input capture register in the itu channel selected in tpcr, tpc output will be triggered by the input capture signal. figure 9.8 shows the timing. figure 9.8 tpc output triggering by input capture (example)
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 315 of 682 rej09b0353-0300 9.4 usage notes 9.4.1 operation of tpc output pins tp 0 to tp 15 * are multiplexed with itu pin functions. when itu output is enabled, the corresponding pins cannot be used for tpc output. the data transfer from ndr bits to dr bits takes place, however, regardless of the usage of the pin. pin functions should be changed only under conditions in which the output trigger event will not occur. note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output to the outside. 9.4.2 note on non-overlapping output during non-overlapping operation, the transfer of ndr bit values to dr bits takes place as follows. 1. ndr bits are always transferred to dr bits at compare match a. 2. at compare match b, ndr bits are transferred only if their value is 0. bits are not transferred if their value is 1. figure 9.9 illustrates the non-overlapping tpc output operation. ddr nder qq tpc output pin dr ndr c qd qd compare match a compare match b figure 9.9 non-overlapping tpc output
section 9 programmable timing pattern controller rev.3.00 mar. 26, 2007 page 316 of 682 rej09b0353-0300 therefore, 0 data can be transferred ahead of 1 data by making compare match b occur before compare match a. ndr contents should not be altered during the interval from compare match b to compare match a (the non-overlap margin). this can be accomplished by having the imfa interrupt service routine write the next data in ndr, or by having the imfa interrupt activate the dmac. the next data must be written before the next compare match b occurs. figure 9.10 shows the timing relationships. compare match a compare match b ndr write ndr ndr write dr 0/1 output 0/1 output 0 output 0 output do not write to ndr in this interval do not write to ndr in this interval write to ndr in this interval write to ndr in this interval figure 9.10 non-overlapping operation and ndr write timing
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 317 of 682 rej09b0353-0300 section 10 watchdog timer 10.1 overview the h8/3039 group has an on-chip watchdog timer (wdt). the wdt has two selectable functions: it can operate as a watchdog timer to supervise system operation, or it can operate as an interval timer. as a watchdog timer, it generates a reset signal for the h8/3039 group chip if a system crash allows the timer counter (tcnt) to overflow before being rewritten. in interval timer operation, an interval timer interrupt is requested at each tcnt overflow. 10.1.1 features wdt features are listed below. ? selection of eight counter clock sources /2, /32, /64, /128, /256, /512, /2048, or /4096 ? interval timer option ? timer counter overflow generates a reset signal or interrupt. the reset signal is generated in watchdog timer operation. an interval timer interrupt is generated in interval timer operation. ? watchdog timer reset signal resets the entire h8/3039 group chip internally, and can also be output externally.* the reset signal generated by timer counter overflow during watchdog timer operation resets the entire h8/3039 group internally. an external reset signal can be output from the reso pin to reset other system devices simultaneously. note: * the reso pin of the mask rom version is the dedicated fwe input pin of the f- ztat version. therefore, the f-ztat version cannot output the reset signal to the outside.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 318 of 682 rej09b0353-0300 10.1.2 block diagram figure 10.1 shows a block diagram of the wdt. /2 /32 /64 /128 /256 /512 /2048 /4096 tcnt tcsr rstcsr reset control interrupt signal reset (internal, external) (interval timer) interrupt control overflow clock clock selector read/ write control internal data bus internal clock sources legend: tcnt: tcsr: rstcsr: timer counter timer control/status register reset control/status register figure 10.1 wdt block diagram 10.1.3 pin configuration table 10.1 describes the wdt output pin.* note: * shows the mask rom version pin. the f-ztat does not have any pins used by the wdt. for f-ztat version, see section 15.9, notes on flash memory programming/erasing. table 10.1 wdt pin name abbreviation i/o function reset output reso output * external output of the watchdog timer reset signal note: * open-drain output. externally pull-up to vcc whether or not the reset output is used
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 319 of 682 rej09b0353-0300 10.1.4 register configuration table 10.2 summarizes the wdt registers. table 10.2 wdt registers address * 1 write * 2 read name abbreviation r/w initial value h'ffa8 h'ffa8 timer control/status register tcsr r/(w) * 3 h'18 h'ffa9 timer counter tcnt r/w h'00 h'ffaa h'ffab reset control/status register rstcsr r/(w) * 3 h'3f notes: 1. lower 16 bits of the address. 2. write word data starting at this address. 3. only 0 can be written in bit 7 to clear the flag. 10.2 register descriptions 10.2.1 timer counter (tcnt) tcnt is an 8-bit readable and writable* up-counter. bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w when the tme bit is set to 1 in tcsr, tcnt starts counting pulses generated from an internal clock source selected by bits cks2 to cks0 in tcsr. when the count overflows (changes from h'ff to h'00), the ovf bit is set to 1 in tcsr. tcnt is initialized to h'00 by a reset and when the tme bit is cleared to 0. note: * tcnt is write-protected by a password. for details see section 10.2.4, notes on register access.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 320 of 682 rej09b0353-0300 10.2.2 timer control/status register (tcsr) tcsr is an 8-bit readable and writable* register. its functions include selecting the timer mode and clock source. note: * tcsr is write-protected by a password. for details see section 10.2.4, notes on register access. bit initial value read/write note: * only 0 can be written to clear the flag. 7 ovf 0 r/(w) * 6 wt/ it 0 r/w 5 tme 0 r/w 4 ? 1 ? 3 ? 1 ? 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w overflow flag status flag indicating overflow clock select these bits select the tcnt clock source timer mode select selects the mode timer enable selects whether tcnt runs or halts reserved bits bits 7 to 5 are initialized to 0 by a reset and in standby mode. bits 2 to 0 are initialized to 0 by a reset. in software standby mode bits 2 to 0 are not initialized, but retain their previous values.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 321 of 682 rej09b0353-0300 bit 7?overflow flag (ovf): this status flag indicates that the timer counter has overflowed from h'ff to h'00. bit 7 ovf description 0 [clearing condition] cleared by reading ovf when ovf = 1, then writing 0 in ovf (initial value) 1 [setting condition] set when tcnt changes from h'ff to h'00 bit 6?timer mode select (wt/ it it it it ): selects whether to use the wdt as a watchdog timer or interval timer. if used as an interval timer, the wdt generates an interval timer interrupt request when tcnt overflows. if used as a watchdog timer, the wdt generates a reset signal when tcnt overflows. bit 6 wt/ it it it it description 0 interval timer: requests interval timer interrupts (initial value) 1 watchdog timer: generates a reset signal bit 5?timer enable (tme): selects whether tcnt runs or is halted. bit 5 tme description 0 tcnt is initialized to h'00 and halted (initial value) 1 tcnt is counting bits 4 and 3?reserved: these bits cannot be modified and are always read as 1. bits 2 to 0?clock select 2 to 0 (cks2/1/0): these bits select one of eight internal clock sources, obtained by prescaling the system clock ( ), for input to tcnt.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 322 of 682 rej09b0353-0300 bit 2 cks2 bit 1 cks1 bit 0 cks0 description 000 /2 (initial value) 1 /32 10 /64 1 /128 100 /256 1 /512 10 /2048 1 /4096 10.2.3 reset control/status register (rstcsr) rstcsr is an 8-bit readable and writable* register that indicates when a reset signal has been generated by watchdog timer overflow, and controls external output of the reset signal. note: * rstcsr is write-protected by a password. for details see section 10.2.4, notes on register access. bit initial value read/write notes: 1. only 0 can be written in bit 7 to clear the flag. 2. with the mask rom version, enable and disable can be set. with the f-ztat version, do not set enable. 7 wrst 0 r/(w) * 1 6 rstoe 0 r/w 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? watchdog timer reset indicates that a reset signal has been generated reserved bits reset output enable * 2 enables or disables external output of the reset signal bits 7 and 6 are initialized by input of a reset signal at the res pin. they are not initialized by reset signals generated by watchdog timer overflow.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 323 of 682 rej09b0353-0300 bit 7?watchdog timer reset (wrst): during watchdog timer operation, this bit indicates that tcnt has overflowed and generated a reset signal. this reset signal resets the entire chip internally. if bit rstoe is set to 1, this reset signal is also output (low) at the reso pin* 1 to initialize external system devices. bit 7 wrst description 0 [clearing conditions] (initial value) (1) cleared to 0 by reset signal input at res pin (2) cleared by reading wrst when wrst = 1, then writing 0 in werst 1 [setting condition] set when tcnt overflow generates a reset signal during watchdog timer operation bit 6?reset output enable (rstoe): enables or disables external output at the reso pin* 1 of the reset signal generated if tcnt overflows during watchdog timer operation. bit 6 rstoe description 0 reset signal is not output externally (initial value) 1 reset signal is output externally * 2 notes: 1. mask rom version. dedicated fwe input pin for f-ztat version. 2. mask rom version. do not set to 1 with the f-ztat version. bits 5 to 0?reserved: these bits cannot be modified and are always read as 1.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 324 of 682 rej09b0353-0300 10.2.4 notes on register access the watchdog timer's tcnt, tcsr, and rstcsr registers differ from other registers in being more difficult to write. the procedures for writing and reading these registers are given below. writing to tcnt and tcsr these registers must be written by a word transfer instruction. they cannot be written by byte instructions. figure 10.2 shows the format of data written to tcnt and tcsr. tcnt and tcsr both have the same write address. the write data must be contained in the lower byte of the written word. the upper byte must contain h'5a (password for tcnt) or h'a5 (password for tcsr). this transfers the write data from the lower byte to tcnt or tcsr. 15 8 7 0 h'5a write data address h'ffa8 * 15 8 7 0 h'a5 write data address h'ffa8 * tcnt write tcsr write note: * lower 16 bits of the address. figure 10.2 format of data written to tcnt and tcsr
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 325 of 682 rej09b0353-0300 writing to rstcsr rstcsr must be written by a word transfer instruction. it cannot be written by byte transfer instructions. figure 10.3 shows the format of data written to rstcsr. to write 0 in the wrst bit, the write data must have h'a5 in the upper byte and h'00 in the lower byte. the h'00 in the lower byte clears the wrst bit in rstcsr to 0. to write to the rstoe bit, the upper byte must contain h'5a and the lower byte must contain the write data. writing this word transfers a write data value into the rstoe bit. 15 8 7 0 h'a5 h'00 address h'ffaa * 15 8 7 0 h'5a write data address h'ffaa * writing 0 in wrst bit writing to rstoe bit note: * lower 16 bits of the address. figure 10.3 format of data written to rstcsr reading tcnt, tcsr, and rstcsr these registers are read like other registers. byte access instructions can be used. the read addresses are h'ffa8 for tcsr, h'ffa9 for tcnt, and h'ffab for rstcsr, as listed in table 10.3. table 10.3 read addresses of tcnt, tcsr, and rstcsr address * register h'ffa8 tcsr h'ffa9 tcnt h'ffab rstcsr note: * lower 16 bits of the address.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 326 of 682 rej09b0353-0300 10.3 operation operations when the wdt is used as a watchdog timer and as an interval timer are described below. 10.3.1 watchdog timer operation figure 10.4 illustrates watchdog timer operation. to use the wdt as a watchdog timer, set the wt/ it and tme bits to 1 in tcsr. software must prevent tcnt overflow by rewriting the tcnt value (normally by writing h'00) before overflow occurs. if tcnt fails to be rewritten and overflows due to a system crash etc., the h8/3039 group is internally reset for a duration of 518 states. the watchdog reset signal can be externally output from the reso pin* to reset external system devices. the reset signal is output externally for 132 states. external output can be enabled or disabled by the rstoe bit in rstcsr. a watchdog reset has the same vector as a reset generated by input at the res pin. software can distinguish a res reset from a watchdog reset by checking the wrst bit in rstcsr. if a res reset and a watchdog reset occur simultaneously, the res reset takes priority. note: * mask rom version. since the res pin is a dedicated fwe input pin with the f-ztat version, the reset signal cannot be output to the outside.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 327 of 682 rej09b0353-0300 h'ff h'00 reso wdt overflow start h'00 written in tcnt reset tme set to 1 h'00 written in tcnt internal reset signal 518 states 132 states tcnt count value ovf = 1 figure 10.4 watchdog timer operation (mask rom version) 10.3.2 interval timer operation figure 10.5 illustrates interval timer operation. to use the wdt as an interval timer, clear bit wt/ it to 0 and set bit tme to 1 in tcsr. an interval timer interrupt request is generated at each tcnt overflow. this function can be used to generate interval timer interrupts at regular intervals. tcnt count value time t interval timer interrupt interval timer interrupt interval timer interrupt interval timer interrupt interval timer interrupt wt/ = 0 tme = 1 it h'ff h'00 figure 10.5 interval timer operation
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 328 of 682 rej09b0353-0300 10.3.3 timing of setting of overflow flag (ovf) figure 10.6 shows the timing of setting of the ovf flag in tcsr. the ovf flag is set to 1 when tcnt overflows. at the same time, a reset signal is generated in watchdog timer operation, or an interval timer interrupt is generated in interval timer operation. tcnt overflow signal ovf h'ff h'00 figure 10.6 timing of setting of ovf
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 329 of 682 rej09b0353-0300 10.3.4 timing of setting of watchdog timer reset bit (wrst) the wrst bit in rstcsr is valid when bits wt/ it and tme are both set to 1 in tcsr. figure 10.7 shows the timing of setting of wrst and the internal reset timing. the wrst bit is set to 1 when tcnt overflows and ovf is set to 1. at the same time an internal reset signal is generated for the entire h8/3039 group chip. this internal reset signal clears ovf to 0, but the wrst bit remains set to 1. the reset routine must therefore clear the wrst bit. tcnt overflow signal ovf wrst h'ff h'00 wdt internal reset figure 10.7 timing of setting of wrst bit and internal reset 10.4 interrupts during interval timer operation, an overflow generates an interval timer interrupt (wovi). the interval timer interrupt is requested whenever the ovf bit is set to 1 in tcsr.
section 10 watchdog timer rev.3.00 mar. 26, 2007 page 330 of 682 rej09b0353-0300 10.5 usage notes contention between tcnt write and increment if a timer counter clock pulse is generated during the t3 state of a write cycle to tcnt, the write takes priority and the timer count is not incremented. see figure 10.8. tcnt tcnt nm counter write data t 3 t 2 t 1 write cycle: cpu writes to tcnt internal write signal tcnt input clock figure 10.8 contention between tcnt write and increment changing cks2 to cks0 values halt tcnt by clearing the tme bit to 0 in tcsr before changing the values of bits cks2 to cks0.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 331 of 682 rej09b0353-0300 section 11 serial communication interface 11.1 overview the h8/3039 group has a serial communication interface (sci) with two independent channels. the two channels are functionally identical. the sci can communicate in asynchronous or synchronous mode. it also has a multiprocessor communication function for serial communication among two or more processors. when the sci is not used, it can be halted to conserve power. each sci channel can be halted independently. for details see section 17.6, module standby function. channel 0 (sci0) also has a smart card interface function conforming to the iso/iec7816-3 (identification card) standard. this function supports serial communication with a smart card. for details, see section 12, smart card interface. 11.1.1 features sci features are listed below. ? selection of asynchronous or synchronous mode for serial communication a. asynchronous mode serial data communication is synchronized one character at a time. the sci can communicate with a universal asynchronous receiver/transmitter (uart), asynchronous communication interface adapter (acia), or other chip that employs standard asynchronous serial communication. it can also communicate with two or more other processors using the multiprocessor communication function. there are twelve selectable serial data communication formats. ? data length: 7 or 8 bits ? stop bit length: 1 or 2 bits ? parity bit: even, odd, or none ? multiprocessor bit: 1 or 0 ? receive error detection: parity, overrun, and framing errors ? break detection: by reading the rxd level directly when a framing error occurs
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 332 of 682 rej09b0353-0300 b. synchronous mode serial data communication is synchronized with a clock signal. the sci can communicate with other chips having a synchronous communication function. there is one serial data communication format. ? data length: 8 bits ? receive error detection: overrun errors ? full-duplex communication the transmitting and receiving sections are independent, so the sci can transmit and receive simultaneously. the transmitting and receiving sections are both double-buffered, so serial data can be transmitted and received continuously. ? built-in baud rate generator with selectable bit rates ? selectable transmit/receive clock sources: internal clock from baud rate generator, or external clock from the sck pin. ? four types of interrupts transmit-data-empty, transmit-end, receive-data-full, and receive-error interrupts are requested independently.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 333 of 682 rej09b0353-0300 11.1.2 block diagram figure 11.1 shows a block diagram of the sci. rxd txd sck rdr rsr tdr tsr ssr scr smr brr module data bus bus interface internal data bus transmit/ receive control baud rate generator /4 /16 /64 clock parity generation parity check tei txi rxi eri legend: external clock rsr: rdr: tsr: tdr: smr: scr: ssr: brr: receive shift register receive data register transmit shift register transmit data register serial mode register serial control register serial status register bit rate register figure 11.1 sci block diagram
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 334 of 682 rej09b0353-0300 11.1.3 input/output pins the sci has the serial pins for each channel as listed in table 11.1. table 11.1 sci pins channel name abbreviation i/o function 0 serial clock pin sck 0 input/output sci 0 clock input/output receive data pin rxd 0 input sci 0 receive data input transmit data pin txd 0 output sci 0 transmit data output 1 serial clock pin sck 1 input/output sci 1 clock input/output receive data pin rxd 1 input sci 1 receive data input transmit data pin txd 1 output sci 1 transmit data output
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 335 of 682 rej09b0353-0300 11.1.4 register configuration the sci has the internal registers as listed in table 11.2. these registers select asynchronous or synchronous mode, specify the data format and bit rate, and control the transmitter and receiver sections. table 11.2 registers channel address * 1 name abbreviation r/w initial value 0 h'ffb0 serial mode register smr r/w h'00 h'ffb1 bit rate register brr r/w h'ff h'ffb2 serial control register scr r/w h'00 h'ffb3 transmit data register tdr r/w h'ff h'ffb4 serial status register ssr r/(w) * 2 h'84 h'ffb5 receive data register rdr r h'00 1 h'ffb8 serial mode register smr r/w h'00 h'ffb9 bit rate register brr r/w h'ff h'ffba serial control register scr r/w h'00 h'ffbb transmit data register tdr r/w h'ff h'ffbc serial status register ssr r/(w) * 2 h'84 h'ffbd receive data register rdr r h'00 notes: 1. lower 16 bits of the address. 2. only 0 can be written to clear flags.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 336 of 682 rej09b0353-0300 11.2 register descriptions 11.2.1 receive shift register (rsr) rsr is an 8-bit register that receives serial data. bit read/write 7 ? 6 ? 5 ? 4 ? 3 ? 0 ? 2 ? 1 ? the sci loads serial data input at the rxd pin into rsr in the order received, lsb (bit 0) first, thereby converting the data to parallel data. when 1 byte has been received, it is automatically transferred to rdr. the cpu cannot read or write rsr directly. 11.2.2 receive data register (rdr) rdr is an 8-bit register that stores received serial data. bit initial value read/write 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r when the sci finishes receiving 1 byte of serial data, it transfers the received data from rsr into rdr for storage. rsr is then ready to receive the next data. this double buffering allows data to be received continuously. rdr is a read-only register. its contents cannot be modified by the cpu. rdr is initialized to h'00 by a reset and in standby mode.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 337 of 682 rej09b0353-0300 11.2.3 transmit shift register (tsr) tsr is an 8-bit register used to transmit serial data. bit read/write 7 ? 6 ? 5 ? 4 ? 3 ? 0 ? 2 ? 1 ? the sci loads transmit data from tdr into tsr, then transmits the data serially from the txd pin, lsb (bit 0) first. after transmitting one data byte, the sci automatically loads the next transmit data from tdr into tsr and starts transmitting it. if the tdre flag is set to 1 in ssr, however, the sci does not load the tdr contents into tsr. the cpu cannot read or write tsr directly. 11.2.4 transmit data register (tdr) tdr is an 8-bit register that stores data for serial transmission. bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w when the sci detects that tsr is empty, it moves transmit data written in tdr from tdr into tsr and starts serial transmission. continuous serial transmission is possible by writing the next transmit data in tdr during serial transmission from tsr. the cpu can always read and write tdr. tdr is initialized to h'ff by a reset and in standby mode.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 338 of 682 rej09b0353-0300 11.2.5 serial mode register (smr) smr is an 8-bit register that specifies the sci serial communication format and selects the clock source for the baud rate generator. bit initial value read/write 7 c/ a 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 o/ e 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w communication mode selects asynchronous or synchronous mode clock select 1/0 these bits select the baud rate generator ? s clock source character length selects character length in asynchronous mode parity enable selects whether a parity bit is added parity mode selects even or odd parity stop bit length selects the stop bit length multiprocessor mode selects the multiprocessor function the cpu can always read and write smr. smr is initialized to h'00 by a reset and in standby mode. bit 7?communication mode (c/ a a a a ): selects whether the sci operates in asynchronous or synchronous mode. bit 7 c/ a a a a description 0 asynchronous mode (initial value) 1 synchronous mode
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 339 of 682 rej09b0353-0300 bit 6?character length (chr): selects 7-bit or 8-bit data length in asynchronous mode. in synchronous mode the data length is 8 bits regardless of the chr setting. bit 6 chr description 0 8-bit data (initial value) 1 7-bit data * note: * when 7-bit data is selected, the msb (bit 7) in tdr is not transmitted. bit 5?parity enable (pe): in asynchronous mode, this bit enables or disables the addition of a parity bit to transmit data, and the checking of the parity bit in receive data. in synchronous mode the parity bit is neither added nor checked, regardless of the pe setting. bit 5 pe description 0 parity bit not added or checked (initial value) 1 parity bit added and checked * note: * when pe is set to 1, an even or odd parity bit is added to transmit data according to the even or odd parity mode selected by the o/ e bit, and the parity bit in receive data is checked to see that it matches the even or odd mode selected by the o/ e bit. bit 4?parity mode (o/ e e e e ): selects even or odd parity. the o/ e bit setting is valid in asynchronous mode when the pe bit is set to 1 to enable the adding and checking of a parity bit. the o/ e setting is ignored in synchronous mode, or when parity adding and checking is disabled in asynchronous mode. bit 4 o/ e e e e description 0 even parity * 1 (initial value) 1 odd parity * 2 notes: 1. when even parity is selected, the parity bit added to transmit data makes an even number of 1s in the transmitted character and parity bit combined. receive data must have an even number of 1s in the received character and parity bit combined. 2. when odd parity is selected, the parity bit added to transmit data makes an odd number of 1s in the transmitted character and parity bit combined. receive data must have an odd number of 1s in the received character and parity bit combined. bit 3?stop bit length (stop): selects one or two stop bits in asynchronous mode. this setting is used only in asynchronous mode. in synchronous mode no stop bit is added, so the stop bit setting is ignored.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 340 of 682 rej09b0353-0300 bit 3 stop description 0 one stop bit * 1 (initial value) 1 two stop bits * 2 notes: 1. one stop bit (with value 1) is added at the end of each transmitted character. 2. two stop bits (with value 1) are added at the end of each transmitted character. in receiving, only the first stop bit is checked, regardless of the stop bit setting. if the second stop bit is 1 it is treated as a stop bit. if the second stop bit is 0 it is treated as the start bit of the next incoming character. bit 2?multiprocessor mode (mp): selects a multiprocessor format. when a multiprocessor format is selected, parity settings made by the pe and o/ e bits are ignored. the mp bit setting is valid only in asynchronous mode. it is ignored in synchronous mode. for further information on the multiprocessor communication function, see section 11.3.3, multiprocessor communication. bit 2 mp description 0 multiprocessor function disabled (initial value) 1 multiprocessor format selected bits 1 and 0?clock select 1 and 0 (cks1/0): these bits select the clock source of the on-chip baud rate generator. four clock sources are available: , /4, /16, and /64. for the relationship between the clock source, bit rate register setting, and baud rate, see section 11.2.8, bit rate register (brr). bit 1 cks1 bit 0 cks0 description 00 clock selected (initial value) 01 /4 clock selected 10 /16 clock selected 11 /64 clock selected
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 341 of 682 rej09b0353-0300 11.2.6 serial control register (scr) scr enables the sci transmitter and receiver, enables or disables serial clock output in asynchronous mode, enables or disables interrupts, and selects the transmit/receive clock source. bit initial value read/write 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w transmit interrupt enable enables or disables transmit-data-empty interrupts (txi) clock enable 1/0 these bits select the sci clock source receive interrupt enable enables or disables receive-data-full interrupts (rxi) and receive-error interrupts (eri) transmit enable enables or disables the transmitter receive enable enables or disables the receiver multiprocessor interrupt enable enables or disables multiprocessor interrupts transmit end interrupt enable enables or disables transmit- end interrupts (tei) the cpu can always read and write scr. scr is initialized to h'00 by a reset and in standby mode.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 342 of 682 rej09b0353-0300 bit 7?transmit interrupt enable (tie): enables or disables the transmit-data-empty interrupt (txi) requested when the tdre flag in ssr is set to 1 due to transfer of serial transmit data from tdr to tsr. bit 7 tie description 0 transmit-data-empty interrupt request (txi) is disabled * (initial value) 1 transmit-data-empty interrupt request (txi) is enabled note: * txi interrupt requests can be cleared by reading the value 1 from the tdre flag, then clearing it to 0; or by clearing the tie bit to 0. bit 6?receive interrupt enable (rie): enables or disables the receive-data-full interrupt (rxi) requested when the rdrf flag is set to 1 in ssr due to transfer of serial receive data from rsr to rdr; also enables or disables the receive-error interrupt (eri). bit 6 rie description 0 receive-end (rxi) and receive-error (eri) interrupt requests are disabled * (initial value) 1 receive-end (rxi) and receive-error (eri) interrupt requests are enabled note: * rxi and eri interrupt requests can be cleared by reading the value 1 from the rdrf, fer, per, or orer flag, then clearing it to 0; or by clearing the rie bit to 0. bit 5?transmit enable (te): enables or disables the start of sci serial transmitting operations. bit 5 te description 0 transmitting disabled * 1 (initial value) 1 transmitting enabled * 2 notes: 1. the tdre flag is fixed at 1 in ssr. 2. in the enabled state, serial transmitting starts when the tdre flag in ssr is cleared to 0 after writing of transmit data into tdr. select the transmit format in smr before setting the te bit to 1.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 343 of 682 rej09b0353-0300 bit 4?receive enable (re): enables or disables the start of sci serial receiving operations. bit 4 re description 0 receiving disabled * 1 (initial value) 1 receiving enabled * 2 notes: 1. clearing the re bit to 0 does not affect the rdrf, fer, per, and orer flags. these flags retain their previous values. 2. in the enabled state, serial receiving starts when a start bit is detected in asynchronous mode, or serial clock input is detected in synchronous mode. select the receive format in smr before setting the re bit to 1. bit 3?multiprocessor interrupt enable (mpie): enables or disables multiprocessor interrupts. the mpie setting is valid only in asynchronous mode, and only if the mp bit is set to 1 in smr. the mpie setting is ignored in synchronous mode or when the mp bit is cleared to 0. bit 3 mpie description 0 multiprocessor interrupts are disabled (normal receive operation) (initial value) [clearing conditions] ? the mpie bit is cleared to 0 ? mpb = 1 in received data 1 multiprocessor interrupts are enabled * receive-data-full interrupts (rxi), receive-error interrupts (eri), and setting of the rdrf, fer, and orer status flags in ssr are disabled until data with the multiprocessor bit set to 1 is received. note: * the sci does not transfer receive data from rsr to rdr, does not detect receive errors, and does not set the rdrf, fer, and orer flags in ssr. when it receives data in which mpb = 1, the sci sets the mpb bit to 1 in ssr, automatically clears the mpie bit to 0, and enables rxi and eri interrupts (if the rie bit is set to 1 in scr) and setting of the fer and orer flags.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 344 of 682 rej09b0353-0300 bit 2?transmit-end interrupt enable (teie): enables or disables the transmit-end interrupt (tei) requested if tdr does not contain new transmit data when the msb is transmitted. bit 2 teie description 0 transmit-end interrupt requests (tei) are disabled * (initial value) 1 transmit-end interrupt requests (tei) are enabled * note: * tei interrupt requests can be cleared by reading the value 1 from the tdre flag in ssr, then clearing the tdre flag to 0, thereby also clearing the tend flag to 0; or by clearing the teie bit to 0. bits 1 and 0?clock enable 1 and 0 (cke1/0): these bits select the sci clock source and enable or disable clock output from the sck pin. depending on the settings of cke1 and cke0, the sck pin can be used for generic input/output, serial clock output, or serial clock input. the cke0 setting is valid only in asynchronous mode, and only when the sci is internally clocked (cke1 = 0). the cke0 setting is ignored in synchronous mode, or when an external clock source is selected (cke1 = 1). after setting the cke1 and cke0 bits, select the sci operating mode in smr. for further details on selection of the sci clock source, see table 11.9. bit 1 cke1 bit 0 cke0 description 0 0 asynchronous mode internal clock, sck pin available for generic input/output * 1 synchronous mode internal clock, sck pin used for serial clock output * 1 0 1 asynchronous mode internal clock, sck pin used for clock output * 2 synchronous mode internal clock, sck pin used for serial clock output 1 0 asynchronous mode external clock, sck pin used for clock input * 3 synchronous mode external clock, sck pin used for serial clock input 1 1 asynchronous mode external clock, sck pin used for clock input * 3 synchronous mode external clock, sck pin used for serial clock input notes: 1. initial value 2. the output clock frequency is the same as the bit rate. 3. the input clock frequency is 16 times the bit rate.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 345 of 682 rej09b0353-0300 11.2.7 serial status register (ssr) ssr is an 8-bit register containing multiprocessor bit values, and status flags that indicate the sci operating status. bit initial value read/write note: * only 0 can be written to clear the flag. 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 orer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r transmit data register empty status flag indicating that transmit data has been transferred from tdr into tsr and new data can be written in tdr multiprocessor bit transfer value of multi- processor bit to be transmitted receive data register full status flag indicating that data has been received and stored in rdr overrun error status flag indicating detection of a receive overrun error framing error status flag indicating detection of a receive framing error parity error status flag indicating detection of a receive parity error transmit end status flag indicating end of transmission ***** multiprocessor bit stores the received multiprocessor bit value the cpu can always read and write ssr, but cannot write 1 in the tdre, rdrf, orer, per, and fer flags. these flags can be cleared to 0 only if they have first been read while set to 1. the tend and mpb flags are read-only bits that cannot be written.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 346 of 682 rej09b0353-0300 ssr is initialized to h'84 by a reset and in standby mode. bit 7?transmit data register empty (tdre): indicates that the sci has loaded transmit data from tdr into tsr and the next serial transmit data can be written in tdr. bit 7 tdre description 0 tdr contains valid transmit data [clearing condition] software reads tdre while it is set to 1, then writes 0 1 tdr does not contain valid transmit data (initial value) [setting conditions] ? the chip is reset or enters standby mode ? the te bit in scr is cleared to 0 ? tdr contents are loaded into tsr, so new data can be written in tdr bit 6?receive data register full (rdrf): indicates that rdr contains new receive data. bit 6 rdrf description 0 rdr does not contain new receive data (initial value) [clearing conditions] ? the chip is reset or enters standby mode ? software reads rdrf while it is set to 1, then writes 0 ? the dmac reads data from rdr 1 rdr contains new receive data [setting condition] when serial data is received normally and transferred from rsr to rdr note: the rdr contents and rdrf flag are not affected by detection of receive errors or by clearing of the re bit to 0 in scr. they retain their previous values. if the rdrf flag is still set to 1 when reception of the next data ends, an overrun error occurs and receive data is lost.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 347 of 682 rej09b0353-0300 bit 5?overrun error (orer): indicates that data reception ended abnormally due to an overrun error. bit 5 orer description 0 receiving is in progress or has ended normally (initial value) * 1 [clearing conditions] ? the chip is reset or enters standby mode ? software reads orer while it is set to 1, then writes 0 1 a receive overrun error occurred * 2 [setting condition] reception of the next serial data ends when rdrf = 1 notes: 1. clearing the re bit to 0 in scr does not affect the orer flag, which retains its previous value. 2. rdr continues to hold the receive data before the overrun error, so subsequent receive data is lost. serial receiving cannot continue while the orer flag is set to 1. in synchronous mode, serial transmitting is also disabled. bit 4?framing error (fer): indicates that data reception ended abnormally due to a framing error in asynchronous mode. bit 4 fer description 0 receiving is in progress or has ended normally (initial value) * 1 [clearing conditions] ? the chip is reset or enters standby mode ? software reads fer while it is set to 1, then writes 0 1 a receive framing error occurred * 2 [setting condition] the stop bit at the end of receive data is checked and found to be 0 notes: 1. clearing the re bit to 0 in scr does not affect the fer flag, which retains its previous value. 2. when the stop bit length is 2 bits, only the first bit is checked. the second stop bit is not checked. when a framing error occurs the sci transfers the receive data into rdr but does not set the rdrf flag. serial receiving cannot continue while the fer flag is set to 1. in synchronous mode, serial transmitting is also disabled.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 348 of 682 rej09b0353-0300 bit 3?parity error (per): indicates that data reception ended abnormally due to a parity error in asynchronous mode. bit 3 per description 0 receiving is in progress or has ended normally * 1 (initial value) [clearing condition] the chip is reset or enters standby mode. software reads per while it is set to 1, then writes 0 1 a receive parity error occurred * 2 [setting condition] the number of 1s in receive data, including the parity bit, does not match the even or odd parity setting of o/ e in smr notes: 1. clearing the re bit to 0 in scr does not affect the per flag, which retains its previous value. 2. when a parity error occurs the sci transfers the receive data into rdr but does not set the rdrf flag. serial receiving cannot continue while the per flag is set to 1. in synchronous mode, serial transmitting is also disabled. bit 2?transmit end (tend): indicates that when the last bit of a serial character was transmitted tdr did not contain new transmit data, so transmission has ended. the tend flag is a read-only bit and cannot be written. bit 2 tend description 0 transmission is in progress [clearing condition] software reads tdre while it is set to 1, then writes 0 in the tdre flag 1 end of transmission (initial value) [setting conditions] ? the chip is reset or enters standby mode. the te bit is cleared to 0 in scr ? tdre is 1 when the last bit of a serial character is transmitted
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 349 of 682 rej09b0353-0300 bit 1?multiprocessor bit (mpb): stores the value of the multiprocessor bit in receive data when a multiprocessor format is used in asynchronous mode. mpb is a read-only bit and cannot be written. bit 1 mpb description 0 multiprocessor bit value in receive data is 0 * (initial value) 1 multiprocessor bit value in receive data is 1 note: * if the re bit is cleared to 0 when a multiprocessor format is selected, mpb retains its previous value. bit 0?multiprocessor bit transfer (mpbt): stores the value of the multiprocessor bit added to transmit data when a multiprocessor format is selected for transmitting in asynchronous mode. the mpbt setting is ignored in synchronous mode, when a multiprocessor format is not selected, or when the sci is not transmitting. bit 0 mpbt description 0 multiprocessor bit value in transmit data is 0 (initial value) 1 multiprocessor bit value in transmit data is 1 11.2.8 bit rate register (brr) brr is an 8-bit register that, together with the cks1 and cks0 bits in smr that select the baud rate generator clock source, determines the serial communication bit rate. bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w the cpu can always read and write brr. brr is initialized to h'ff by a reset and in standby mode. the baud rate generator is controlled separately for the individual channels, so different values may be set for each. table 11.3 shows examples of brr settings in asynchronous mode. table 11.4 shows examples of brr settings in synchronous mode.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 350 of 682 rej09b0353-0300 table 11.3 examples of bit rates and brr settings in asynchronous mode (mhz) 2 2.097152 2.4576 3 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 1 141 0.03 1 148 ? 0.04 1 174 ? 0.26 1 212 0.03 150 1 103 0.16 1 108 0.21 1 127 0 1 155 0.16 300 0 207 0.16 0 217 0.21 0 255 0 1 77 0.16 600 0 103 0.16 0 108 0.21 0 127 0 0 155 0.16 1200 0 51 0.16 0 54 ? 0.70 0 63 0 0 77 0.16 2400 0 25 0.16 0 26 1.14 0 31 0 0 38 0.16 4800 0 12 0.16 0 13 ? 2.48 0 15 0 0 19 ? 2.34 9600 0 6 ? 6.99 0 6 ? 2.48 0 7 0 0 9 ? 2.34 19200 0 2 8.51 0 2 13.78 0 3 0 0 4 ? 2.34 31250 0 1 0 0 1 4.86 0 1 22.88 0 2 0 38400 0 1 ? 18.62 0 1 ? 14.67 0 1 0 ?? ? (mhz) 3.6864 4 4.9152 5 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 64 0.70 2 70 0.03 2 86 0.31 2 88 ? 0.25 150 1 191 0 1 207 0.16 1 255 0 2 64 0.16 300 1 95 0 1 103 0.16 1 127 0 1 129 0.16 600 0 191 0 0 207 0.16 0 255 0 1 64 0.16 1200 0 95 0 0 103 0.16 0 127 0 0 129 0.16 2400 0 47 0 0 51 0.16 0 63 0 0 64 0.16 4800 0 23 0 0 25 0.16 0 31 0 0 32 ? 1.36 9600 0 11 0 0 12 0.16 0 15 0 0 15 1.73 19200 0 5 0 0 6 ? 6.99 0 7 0 0 7 1.73 31250 ?? ? 03 0 0 4 ? 1.70 0 4 0 38400 0 2 0 0 2 8.51 0 3 0 0 3 1.73
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 351 of 682 rej09b0353-0300 (mhz) 6 6.144 7.3728 8 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 106 ? 0.44 2 108 0.08 2 130 ? 0.07 2 141 0.03 150 1 77 0.16 2 79 0 2 95 0 2 103 0.16 300 1 155 0.16 1 159 0 1 191 0 1 207 0.16 600 1 77 0.16 1 79 0 1 95 0 1 103 0.16 1200 0 155 0.16 0 159 0 0 191 0 0 207 0.16 2400 0 77 0.16 0 79 0 0 95 0 0 103 0.16 4800 0 38 0.16 0 39 0 0 47 0 0 51 0.16 9600 0 19 ? 2.34 0 19 0 0 23 0 0 25 0.16 19200 0 9 ? 2.34 0 9 0 0 11 0 0 12 0.16 31250 0 5 0 0 5 2.40 0 6 5.33 0 7 0 38400 0 4 ? 2.34 0 4 0 0 5 0 0 6 ? 6.99 (mhz) 9.8304 10 12 12.288 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 174 ? 0.26 2 177 ? 0.25 2 212 0.03 2 217 0.08 150 2 127 0 2 129 0.16 2 155 0.16 2 159 0 300 1 255 0 2 64 0.16 2 77 0.16 2 79 0 600 1 127 0 1 129 0.16 1 155 0.16 1 159 0 1200 0 255 0 1 64 0.16 1 77 0.16 1 79 0 2400 0 127 0 0 129 0.16 0 155 0.16 0 159 0 4800 0 63 0 0 64 0.16 0 77 0.16 0 79 0 9600 0 31 0 0 32 ? 1.36 0 38 0.16 0 39 0 19200 0 15 0 0 15 1.73 0 19 ? 2.34 0 19 0 31250 0 9 ? 1.70 0 9 0 0 11 0 0 11 2.40 38400 0 7 0 0 7 1.73 0 9 ? 2.34 0 9 0
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 352 of 682 rej09b0353-0300 (mhz) 14 14.7456 16 18 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 248 ? 0.17 3 64 0.70 3 70 0.03 3 79 ? 0.12 150 2 181 0.16 2 191 0 2 207 0.16 2 233 0.16 300 2 90 0.16 2 95 0 2 103 0.16 2 116 0.16 600 1 181 0.16 1 191 0 1 207 0.16 1 233 0.16 1200 1 90 0.16 1 95 0 1 103 0.16 1 116 0.16 2400 0 181 0.16 0 191 0 0 207 0.16 0 233 0.16 4800 0 90 0.16 0 95 0 0 103 0.16 0 116 0.16 9600 0 45 ? 0.93 0 47 0 0 51 0.16 0 58 ? 0.69 19200 0 22 ? 0.93 0 23 0 0 25 0.16 0 28 1.02 31250 0 11 0 0 14 ? 1.70 0 15 0 0 17 0.00 38400 0 10 3.57 0 11 0 0 12 0.16 0 14 ? 2.34
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 353 of 682 rej09b0353-0300 table 11.4 examples of bit rates and brr settings in synchronous mode (mhz) 2 4 8 10 16 18 bit rate (bits/s)nnnnnnnnnnnn 110 3 70 ?????????? 250 2 124 2 249 3 124 ?? 3 249 ?? 500 1 249 2 124 2 249 ?? 3 124 3 140 1 k 1 124 1 249 2 124 ?? 2 249 3 69 2.5 k 0 199 1 99 1 199 1 249 2 99 2 112 5 k 0 99 0 199 1 99 1 124 1 199 1 224 10 k 0 49 0 99 0 199 0 249 1 99 1 112 25 k 0 19 0 39 0 79 0 99 0 159 0 179 50 k 0 9 0 19 0 39 0 49 0 79 0 89 100 k 0 4 0 9 0 19 0 24 0 39 0 44 250 k 0 1 0 30709015017 500 k 0 0 * 0103040708 1 m 0 0 * 01 ?? 0304 2 m 0 0 * ?? 01 ?? 2.5 m ?? 00 * ???? 4 m 0 0 * ?? legend: blank: no setting available ? : setting possible, but error occurs * : continuous transmission/reception not possible note: settings with an error of 1% or less are recommended.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 354 of 682 rej09b0353-0300 the brr setting is calculated as follows: asynchronous mode: n = 64 2 2n ? 1 b 10 6 ? 1 synchronous mode: n = 8 2 2n ? 1 b 10 6 ? 1 b: bit rate (bits/s) n: brr setting for baud rate generator (0 n 255) : system clock frequency (mhz) n: baud rate generator clock source (n = 0, 1, 2, 3) (for the clock sources and values of n, see the following table.) smr settings n clock source cks1 cks0 0 00 1 /4 0 1 2 /16 1 0 3 /64 1 1 the bit rate error in asynchronous mode is calculated as follows. error (%) = { 10 6 (n + 1) b 64 2 2n ? 1 ? 1} 100
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 355 of 682 rej09b0353-0300 table 11.5 indicates the maximum bit rates in asynchronous mode for various system clock frequencies. tables 11.6 and 11.7 indicate the maximum bit rates with external clock input. table 11.5 maximum bit rates for various frequencies (asynchronous mode) settings (mhz) maximum bit rate (bits/s) n n 2 62500 0 0 2.097152 65536 0 0 2.4576 76800 0 0 3 93750 0 0 3.6864 115200 0 0 4 125000 0 0 4.9152 153600 0 0 5 156250 0 0 6 187500 0 0 6.144 192000 0 0 7.3728 230400 0 0 8 250000 0 0 9.8304 307200 0 0 10 312500 0 0 12 375000 0 0 12.288 384000 0 0 14 437500 0 0 14.7456 460800 0 0 16 500000 0 0 17.2032 537600 0 0 18 562500 0 0
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 356 of 682 rej09b0353-0300 table 11.6 maximum bit rates with external clock input (asynchronous mode) (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.5000 31250 2.097152 0.5243 32768 2.4576 0.6144 38400 3 0.7500 46875 3.6864 0.9216 57600 4 1.0000 62500 4.9152 1.2288 76800 5 1.2500 78125 6 1.5000 93750 6.144 1.5360 96000 7.3728 1.8432 115200 8 2.0000 125000 9.8304 2.4576 153600 10 2.5000 156250 12 3.0000 187500 12.288 3.0720 192000 14 3.5000 218750 14.7456 3.6864 230400 16 4.0000 250000 17.2032 4.3008 268800 18 4.5000 281250
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 357 of 682 rej09b0353-0300 table 11.7 maximum bit rates with external clock input (synchronous mode) (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.3333 333333.3 4 0.6667 666666.7 6 1.0000 1000000.0 8 1.3333 1333333.3 10 1.6667 1666666.7 12 2.0000 2000000.0 14 2.3333 2333333.3 16 2.6667 2666666.7 18 3.0000 3000000.0
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 358 of 682 rej09b0353-0300 11.3 operation 11.3.1 overview the sci has an asynchronous mode in which characters are synchronized individually, and a synchronous mode in which communication is synchronized with clock pulses. serial communication is possible in either mode. asynchronous or synchronous mode and the communication format are selected in smr, as shown in table 11.8. the sci clock source is selected by the c/ a bit in smr and the cke1 and cke0 bits in scr, as shown in table 11.9. asynchronous mode: ? data length is selectable: 7 or 8 bits. ? parity and multiprocessor bits are selectable, and so is the stop bit length (1 or 2 bits). these selections determine the communication format and character length. ? in receiving, it is possible to detect framing errors, parity errors, overrun errors, and the break state. ? an internal or external clock can be selected as the sci clock source. ? when an internal clock is selected, the sci operates using the on-chip baud rate generator, and can output a serial clock signal with a frequency matching the bit rate. ? when an external clock is selected, the external clock input must have a frequency 16 times the bit rate. (the on-chip baud rate generator is not used.) synchronous mode: ? the communication format has a fixed 8-bit data length. ? in receiving, it is possible to detect overrun errors. ? an internal or external clock can be selected as the sci clock source. ? when an internal clock is selected, the sci operates using the on-chip baud rate generator, and outputs a serial clock signal to external devices. ? when an external clock is selected, the sci operates on the input serial clock. the on-chip baud rate generator is not used.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 359 of 682 rej09b0353-0300 table 11.8 smr settings and serial communication formats smr settings sci communication format bit 7 c/ a a a a bit 6 chr bit 2 mp bit 5 pe bit 3 stop mode data length multi- processor bit parity bit stop bit length 00000 8-bit dataabsentabsent1 bit 00001 asynchronous mode 2 bits 00010 present1 bit 00011 2 bits 01000 7-bit data absent1 bit 01001 2 bits 01010 present1 bit 01011 2 bits 00 1 ? 0 8-bit data present absent 1 bit 00 1 ? 12 bits 01 1 ? 0 7-bit data 1 bit 01 1 ? 1 asynchronous mode (mult i - processor format) 2 bits 1 ???? synchronous mode 8-bit data absent none table 11.9 smr and scr settings and sci clock source selection smr scr settings sci communication format bit 7 c/ a a a a bit 1 cke1 bit 0 cke0 mode clock source sck pin function 0 0 0 sci does not use the sck pin 00 1 internal outputs a clock with frequency matching the bit rate 01 0 01 1 asynchronous mode external inputs a clock with frequency 16 times the bit rate 10 0 10 1 internal outputs the serial clock 11 0 11 1 synchronous mode external inputs the serial clock
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 360 of 682 rej09b0353-0300 11.3.2 operation in asynchronous mode in asynchronous mode each transmitted or received character begins with a start bit and ends with a stop bit. serial communication is synchronized one character at a time. the transmitting and receiving sections of the sci are independent, so full-duplex communication is possible. the transmitter and receiver are both double buffered, so data can be written and read while transmitting and receiving are in progress, enabling continuous transmitting and receiving. figure 11.2 shows the general format of asynchronous serial communication. in asynchronous serial communication the communication line is normally held in the mark (high) state. the sci monitors the line and starts serial communication when the line goes to the space (low) state, indicating a start bit. one serial character consists of a start bit (low), data (lsb first), parity bit (high or low), and stop bit (high), in that order. when receiving in asynchronous mode, the sci synchronizes at the falling edge of the start bit. the sci samples each data bit on the eighth pulse of a clock with a frequency 16 times the bit rate. receive data is latched at the center of each bit. serial data 0 1 1 1 idle (mark) state 1 d0 d1 d2 d3 d4 d5 d6 d7 0/1 (lsb) (msb) start bit transmit or receive data parity bit stop bit one unit of data (character or frame) 1 bit 7 bits or 8 bits 1 bit or no bit 1 bit or 2 bits figure 11.2 data format in asynchronous communication (example: 8-bit data with parity and 2 stop bits)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 361 of 682 rej09b0353-0300 communication formats table 11.10 shows the 12 communication formats that can be selected in asynchronous mode. the format is selected by settings in smr. table 11.10 serial communication formats (asynchronous mode) 123456789101112 8-bit data stop 8-bit data 8-bit data 8-bit data 7-bit data 7-bit data 7-bit data 7-bit data 8 bit data 8 bit data 7-bit data 7-bit data s s s s s s s s s s s s stop stop p stop p stop stop stop stop stop stop stop stop p p mpb stop stop stop mpb mpb mpb stop stop legend: s: stop: p: mpb: start bit stop bit parity bit multiprocessor bit chr pe mp stop smr settings 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 ? ? ? ? 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 serial communication format and frame length stop
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 362 of 682 rej09b0353-0300 clock an internal clock generated by the on-chip baud rate generator or an external clock input from the sck pin can be selected as the sci transmit/receive clock. the clock source is selected by the c/ a bit in smr and bits cke1 and cke0 in scr. see table 11.9. when an external clock is input at the sck pin, it must have a frequency equal to 16 times the desired bit rate. when the sci operates on an internal clock, it can output a clock signal at the sck pin. the frequency of this output clock is equal to the bit rate. the phase is aligned as in figure 11.3 so that the rising edge of the clock occurs at the center of each transmit data bit. 0 d0d1d2d3d4d5d6d70/1 1 1 1 frame figure 11.3 phase relationship between output clock and serial data (asynchronous mode) transmitting and receiving data sci initialization (asynchronous mode): before transmitting or receiving, clear the te and re bits to 0 in scr, then initialize the sci as follows. when changing the communication mode or format, always clear the te and re bits to 0 before following the procedure given below. clearing te to 0 sets the tdre flag to 1 and initializes tsr. clearing re to 0, however, does not initialize the rdrf, per, fer, and orer flags and rdr, which retain their previous contents. when an external clock is used, the clock should not be stopped during initialization or subsequent operation. sci operation becomes unreliable if the clock is stopped. figure 11.4 shows a sample flowchart for initializing the sci.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 363 of 682 rej09b0353-0300 clear te and re bits to 0 in scr transmitting or receiving no ye s 1. 2. 3. 4. select the communication format in smr. write the value corresponding to the bit rate in brr. this step is not necessary when an external clock is used. select communication format in smr 1 set value in brr 2 3 set te or re bit to 1 in scr set rie, tie, teie, and mpie bits as necessary 4 1 bit interval elapsed? wait wait for at least the interval required to transmit or receive 1 bit, then set the te or re bit to 1 in scr. set the rie, tie, teie, and mpie bits as necessary. setting the te or re bit enables the sci to use the txd or rxd pin. start of initialization set cke1 and cke0 bits in scr (leaving te and re bits cleared to 0) select the clock source in scr. clear the rie, tie, teie, mpie, te, and re bits to 0. if clock output is selected in asynchronous mode, clock output starts immediately after the setting is made in scr. figure 11.4 sample flowchart for sci initialization
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 364 of 682 rej09b0353-0300 transmitting serial data (asynchronous mode): figure 11.5 shows a sample flowchart for transmitting serial data and indicates the procedure to follow. start transmitting read tdre flag in ssr tdre = 1? write transmit data in tdr and clear tdre flag to 0 in ssr all data transmitted? end 1 2 3 no yes no yes sci initialization: the transmit data output function of the txd pin is selected automatically. sci status check and transmit data write: read ssr, check that the tdre flag is 1, then write transmit data in tdr and clear the tdre flag to 0. read tend flag in ssr tend = 1? no yes output break signal? no yes clear te bit to 0 in scr 4 1. 2. 3. 4. clear dr bit to 0, set ddr bit to 1 initialize to continue transmitting serial data: after checking that the tdre flag is 1, indicating that data can be written, write data in tdr, then clear the tdre flag to 0. to output a break signal at the end of serial transmission: set the ddr bit to 1 and clear the dr bit to 0 (ddr and dr are i/o port registers), then clear the te bit to 0 in scr. figure 11.5 sample flowchart for transmitting serial data
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 365 of 682 rej09b0353-0300 in transmitting serial data, the sci operates as follows. ? the sci monitors the tdre flag in ssr. when the tdre flag is cleared to 0 the sci recognizes that tdr contains new data, and loads this data from tdr into tsr. ? after loading the data from tdr into tsr, the sci sets the tdre flag to 1 and starts transmitting. if the tie bit is set to 1 in scr, the sci requests a transmit-data-empty interrupt (txi) at this time. serial transmit data is transmitted in the following order from the txd pin: ? start bit: one 0 bit is output. ? transmit data: 7 or 8 bits are output, lsb first. ? parity bit or multiprocessor bit: one parity bit (even or odd parity) or one multiprocessor bit is output. formats in which neither a parity bit nor a multiprocessor bit is output can also be selected. ? stop bit: one or two 1 bits (stop bits) are output. ? mark state: output of 1 continues until the start bit of the next transmit data. ? the sci checks the tdre flag when it outputs the stop bit. if the tdre flag is 0, the sci loads new data from tdr into tsr, outputs the stop bit, then begins serial transmission of the next frame. if the tdre flag is 1, the sci sets the tend flag to 1 in ssr, outputs the stop bit, then continues output of 1 in the mark state. if the teie bit is set to 1 in scr, a transmit-end interrupt (tei) is requested at this time. figure 11.6 shows an example of sci transmit operation in asynchronous mode. 1 start bit 0 d0 d1 d7 0/1 stop bit 1 data parity bit start bit 0 d0 d1 d7 0/1 stop bit 1 data parity bit 1 idle (mark) state tdre tend txi interrupt request txi interrupt handler writes data in tdr and clears tdre flag to 0 txi interrupt request 1 frame tei interrupt request figure 11.6 example of sci transmit operation in asynchronous mode (8-bit data with parity and 1 stop bit)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 366 of 682 rej09b0353-0300 receiving serial data (asynchronous mode): figure 11.7 shows a sample flowchart for receiving serial data and indicates the procedure to follow. start receiving read rdrf flag in ssr rdrf = 1? read receive data from rdr, and clear rdrf flag to 0 in ssr per fer orer = 1? clear re bit to 0 in scr finished receiving? end error handling (continued on next page) 1 4 no yes yes no no yes 1. 2., 3. 4. 5. sci initialization: the receive data function of the rxd pin is selected automatically. receive error handling and break detection: if a receive error occurs, read the orer, per, and fer flags in ssr to identify the error. after executing the necessary error handling, clear the orer, per, and fer flags all to 0. receiving cannot resume if any of the orer, per, and fer flags remains set to 1. when a framing error occurs, the rxd pin can be read to detect the break state. sci status check and receive data read: read ssr, check that rdrf is set to 1, then read receive data from rdr and clear the rdrf flag to 0. notification that the rdrf flag has changed from 0 to 1 can also be given by the rxi interrupt. to continue receiving serial data: check the rdrf flag, read rdr, and clear the rdrf flag to 0 before the stop bit of the current frame is received. read orer, per, and fer flags in ssr 2 5 initialize ? 3 figure 11.7 sample flowchart for receiving serial data (1)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 367 of 682 rej09b0353-0300 no no no no ye s ye s ye s ye s framing error handling per = 1? orer = 1? overrun error handling fer = 1? break? error handling parity error handling clear orer, per, and fer flags to 0 in ssr clear re bit to 0 in scr end 3 figure 11.7 sample flowchart for receiving serial data (2)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 368 of 682 rej09b0353-0300 in receiving, the sci operates as follows. ? the sci monitors the receive data line. when it detects a start bit, the sci synchronizes internally and starts receiving. ? receive data is stored in rsr in order from lsb to msb. ? the parity bit and stop bit are received. after receiving data, the sci makes the following checks: ? parity check: the number of 1s in the receive data must match the even or odd parity setting of the o/ e bit in smr. ? stop bit check: the stop bit value must be 1. if there are two stop bits, only the first stop bit is checked. ? status check: the rdrf flag must be 0 so that receive data can be transferred from rsr into rdr. if these checks all pass, the rdrf flag is set to 1 and the received data is stored in rdr. if one of the checks fails (receive error)*, the sci operates as indicated in table 11.11. note: * when a receive error occurs, further receiving is disabled. in receiving, the rdrf flag is not set to 1. be sure to clear the error flags. ? when the rdrf flag is set to 1, if the rie bit is set to 1 in scr, a receive-data-full interrupt (rxi) is requested. if the orer, per, or fer flag is set to 1 and the rie bit in scr is also set to 1, a receive-error interrupt (eri) is requested. table 11.11 receive error conditions receive error abbreviation condition data transfer overrun error orer receiving of next data ends while rdrf flag is still set to 1 in ssr receive data not transferred from rsr to rdr framing error fer stop bit is 0 receive data transferred from rsr to rdr parity error per parity of receive data differs from even/odd parity setting in smr receive data transferred from rsr to rdr
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 369 of 682 rej09b0353-0300 figure 11.8 shows an example of sci receive operation in asynchronous mode. 1 start bit 0 d0 d1 d7 0/1 stop bit 1 data parity bit start bit 0 d0 d1 d7 0/1 stop bit 1 data parity bit 1 idle (mark) state rdrf fer rxi request 1 frame framing error, eri request rxi interrupt handler reads data in rdr and clears rdrf flag to 0 figure 11.8 example of sci receive operation (8-bit data with parity and one stop bit) 11.3.3 multiprocessor communication the multiprocessor communication function enables several processors to share a single serial communication line. the processors communicate in asynchronous mode using a format with an additional multiprocessor bit (multiprocessor format). in multiprocessor communication, each receiving processor is addressed by an id. a serial communication cycle consists of an id-sending cycle that identifies the receiving processor, and a data-sending cycle. the multiprocessor bit distinguishes id-sending cycles from data-sending cycles. the transmitting processor starts by sending the id of the receiving processor with which it wants to communicate as data with the multiprocessor bit set to 1. next the transmitting processor sends transmit data with the multiprocessor bit cleared to 0. receiving processors skip incoming data until they receive data with the multiprocessor bit set to 1. when they receive data with the multiprocessor bit set to 1, receiving processors compare the data with their ids. the receiving processor with a matching id continues to receive further incoming data. processors with ids not matching the received data skip further incoming data until they again receive data with the multiprocessor bit set to 1. multiple processors can send and receive data in this way. figure 11.9 shows an example of communication among different processors using a multiprocessor format.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 370 of 682 rej09b0353-0300 communication formats four formats are available. parity-bit settings are ignored when a multiprocessor format is selected. for details see table 11.11. clock see the description of asynchronous mode. transmitting processor receiving processor a serial communication line receiving processor b receiving processor c receiving processor d (id = 01) (id = 02) (id = 03) (id = 04) serial data h'01 h'aa (mpb = 1) (mpb = 0) id-sending cycle: receiving processor address data-sending cycle: data sent to receiving processor specified by id legend: mpb: multiprocessor bit figure 11.9 example of communication among processors using multiprocessor format (sending data h'aa to receiving processor a)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 371 of 682 rej09b0353-0300 transmitting and receiving data transmitting multiprocessor serial data: figure 11.10 shows a sample flowchart for transmitting multiprocessor serial data and indicates the procedure to follow. no no no no yes yes yes yes initialize start transmitting read tdre flag in ssr tdre = 1? write transmit data in tdr and set mpbt bit in ssr clear tdre flag to 0 all data transmitted? read tend flag in ssr tend = 1? 1 2 3 4 1. 2. 3. 4. sci initialization: the transmit data output function of the txd pin is selected automatically. sci status check and transmit data write: read ssr, check that the tdre flag is 1, then write transmit data in tdr. also set the mpbt flag to 0 or 1 in ssr. finally, clear the tdre flag to 0. to continue transmitting serial data: after checking that the tdre flag is 1, indicating that data can be written, write data in tdr, then clear the tdre flag to 0. to output a break signal at the end of serial transmission: set the ddr bit to 1 and clear the dr bit to 0 (ddr and dr are i/o port registers), then clear the te bit to 0 in scr. output break signal? clear dr bit to 0, set ddr bit to 1 clear te bit to 0 in scr end figure 11.10 sample flowchart for transmitting multiprocessor serial data
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 372 of 682 rej09b0353-0300 in transmitting serial data, the sci operates as follows. ? the sci monitors the tdre flag in ssr. when the tdre flag is cleared to 0 the sci recognizes that tdr contains new data, and loads this data from tdr into tsr. ? after loading the data from tdr into tsr, the sci sets the tdre flag to 1 and starts transmitting. if the tie bit in scr is set to 1, the sci requests a transmit-data-empty interrupt (txi) at this time. serial transmit data is transmitted in the following order from the txd pin: ? start bit: one 0 bit is output. ? transmit data: 7 or 8 bits are output, lsb first. ? multiprocessor bit: one multiprocessor bit (mpbt value) is output. ? stop bit: one or two 1 bits (stop bits) are output. ? mark state: output of 1 bits continues until the start bit of the next transmit data. ? the sci checks the tdre flag when it outputs the stop bit. if the tdre flag is 0, the sci loads data from tdr into tsr, outputs the stop bit, then begins serial transmission of the next frame. if the tdre flag is 1, the sci sets the tend flag in ssr to 1, outputs the stop bit, then continues output of 1 bits in the mark state. if the teie bit is set to 1 in scr, a transmit-end interrupt (tei) is requested at this time. figure 11.11 shows an example of sci transmit operation using a multiprocessor format. 1 start bit 0 d0 d1 d7 0/1 stop bit 1 data multi- processor bit start bit 0 d0 d1 d7 0/1 stop bit 1 data 1 idle (mark) state tdre tend txi request txi interrupt handler writes data in tdr and clears tdre flag to 0 txi request 1 frame tei request serial data multi- processor bit figure 11.11 example of sci transmit operation (8-bit data with multiprocessor bit and one stop bit)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 373 of 682 rej09b0353-0300 receiving multiprocessor serial data: figure 11.12 shows a sample flowchart for receiving multiprocessor serial data and indicates the procedure to follow. initialize start receiving read rdrf flag in ssr rdrf = 1? read receive data from rdr read orer and fer flags in ssr fer orer = 1 ? read rdrf flag in ssr read receive data from rdr rdrf = 1? finished receiving? clear re bit to 0 in scr error handling (continued on next page) end 1 2 4 5 1. 2. 3. 4. 5. sci initialization: the receive data function of the rxd pin is selected automatically. id receive cycle: set the mpie bit to 1 in scr. sci status check and id check: read ssr, check that the rdrf flag is set to 1, then read data from rdr and compare with the processor's own id. if the id does not match, set the mpie bit to 1 again and clear the rdrf flag to 0. if the id matches, clear the rdrf flag to 0. sci status check and data receiving: read ssr, check that the rdrf flag is set to 1, then read data from rdr. receive error handling and break detection: if a receive error occurs, read the orer and fer flags in ssr to identify the error. after executing the necessary error handling, clear the orer and fer flags both to 0. receiving cannot resume while either the orer or fer flag remains set to 1. when a framing error occurs, the rxd pin can be read to detect the break state. yes yes yes no yes yes no no no 3 set mpie bit to 1 in scr read orer and fer flags in ssr yes fer orer = 1 ? own id? no no figure 11.12 sample flowchart for receiving multiprocessor serial data (1)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 374 of 682 rej09b0353-0300 no no yes no yes yes error handling orer = 1? overrun error handling fer = 1? break? framing error handling clear orer and fer flags to 0 in ssr clear re bit to 0 in scr end 5 figure 11.12 sample flowchart for receiving multiprocessor serial data (2)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 375 of 682 rej09b0353-0300 figure 11.13 shows an example of sci receive operation using a multiprocessor format. 1 start bit 0 d0 d1 d7 1 stop bit 1 data (id1) mpb start bit 0 d0 d1 d7 0 stop bit 1 data (data1) mpb 1 idle (mark) state mpie rdrf rdr value id1 rxi request (multiprocessor interrupt), mpie = 0 rxi handler reads rdr data and clears rdrf flag to 0 not own id, so mpie bit is set to 1 again no rxi request, rdr not updated a. own id does not match data 1 start bit 0 d0 d1 d7 1 stop bit 1 data (id2) mpb start bit 0 d0 d1 d7 0 stop bit 1 data (data2) mpb 1 idle (mark) state mpie rdrf rdr value id2 rxi request (multiprocessor interrupt), mpie = 0 rxi interrupt handler reads rdr data and clears rdrf flag to 0 own id, so receiving continues, with data received by rxi interrupt handler mpie bit is set to 1 again b. own id matches data id1 data 2 figure 11.13 example of sci receive operation (8-bit data with multiprocessor bit and one stop bit)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 376 of 682 rej09b0353-0300 11.3.4 synchronous operation in synchronous mode, the sci transmits and receives data in synchronization with clock pulses. this mode is suitable for high-speed serial communication. the sci transmitter and receiver share the same clock but are otherwise independent, so full duplex communication is possible. the transmitter and receiver are also double buffered, so continuous transmitting or receiving is possible by reading or writing data while transmitting or receiving is in progress. figure 11.14 shows the general format in synchronous serial communication. serial clock serial data bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 lsb msb don't care don't care one unit (character or frame) of serial data transfer direction * * note: * high except in continuous transmitting or receiving figure 11.14 data format in synchronous communication in synchronous serial communication, each data bit is placed on the communication line from one falling edge of the serial clock to the next. data is guaranteed valid at the rise of the serial clock. in each character, the serial data bits are transmitted in order from lsb (first) to msb (last). after output of the msb, the communication line remains in the state of the msb. in synchronous mode the sci receives data by synchronizing with the rise of the serial clock. communication format the data length is fixed at 8 bits. no parity bit or multiprocessor bit can be added. clock an internal clock generated by the on-chip baud rate generator or an external clock input from the sck pin can be selected by clearing or setting the cke1 and cke0 bits in scr and the c/ a bit in smr. see table 11.9. when the sci operates on an internal clock, it outputs the clock signal at the sck pin. eight clock pulses are output per transmitted or received character. when the sci is not transmitting or receiving, the clock signal remains in the high state.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 377 of 682 rej09b0353-0300 transmitting and receiving data sci initialization (synchronous mode): before transmitting or receiving, clear the te and re bits to 0 in scr, then initialize the sci as follows. when changing the communication mode or format, always clear the te and re bits to 0 before following the procedure given below. clearing the te bit to 0 sets the tdre flag to 1 and initializes tsr. clearing the re bit to 0, however, does not initialize the rdrf, per, fer, and ore flags and rdr, which retain their previous contents. figure 11.15 shows a sample flowchart for initializing the sci. clear te and re bits to 0 in scr 1 bit interval elapsed? start transmitting or receiving no yes 1. 2. 3. 4. select the clock source in scr. clear the rie, tie, teie, mpie, te, and re bits to 0. select the communication format in smr. write the value corresponding to the bit rate in brr. this step is not necessary when an external clock is used. note: in simultaneous transmitting and receiving, the te and re bits should be cleared to 0 or set to 1 simultaneously. 1 2 set cke1 and cke0 bits in scr (leaving te and re bits cleared to 0) 3 set te or re to 1 in scr set rie, tie, and teie bits as necessary 4 wait wait for at least the interval required to transmit or receive one bit, then set the te or re bit to 1 in scr. also set the rie, tie, and teie bits as necessary. setting the te or re bit enables the sci to use the txd or rxd pin. start of initialization set value in brr select communication format in smr figure 11.15 sample flowchart for sci initialization
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 378 of 682 rej09b0353-0300 transmitting serial data (synchronous mode): figure 11.16 shows a sample flowchart for transmitting serial data and indicates the procedure to follow. start transmitting read tdre flag in ssr tdre = 1? write transmit data in tdr and clear tdre flag to 0 in ssr end 1 2 3 no yes no yes sci initialization: the transmit data output function of the txd pin is selected automatically. sci status check and transmit data write: read ssr, check that the tdre flag is 1, then write transmit data in tdr and clear the tdre flag to 0. read tend flag in ssr no yes 1. 2. 3. initialize clear te bit to 0 in scr to continue transmitting serial data: after checking that the tdre flag is 1, indicating that data can be written, write data in tdr, then clear the tdre flag to 0. all data transmitted? tend = 1? figure 11.16 sample flowchart for serial transmitting
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 379 of 682 rej09b0353-0300 in transmitting serial data, the sci operates as follows. ? the sci monitors the tdre flag in ssr. when the tdre flag is cleared to 0 the sci recognizes that tdr contains new data, and loads this data from tdr into tsr. ? after loading the data from tdr into tsr, the sci sets the tdre flag to 1 and starts transmitting. if the tie bit is set to 1 in scr, the sci requests a transmit-data-empty interrupt (txi) at this time. if clock output is selected, the sci outputs eight serial clock pulses. if an external clock source is selected, the sci outputs data in synchronization with the input clock. data is output from the txd pin in order from lsb (bit 0) to msb (bit 7). ? the sci checks the tdre flag when it outputs the msb (bit 7). if the tdre flag is 0, the sci loads data from tdr into tsr and begins serial transmission of the next frame. if the tdre flag is 1, the sci sets the tend flag to 1 in ssr, and after transmitting the msb, holds the txd pin in the msb state. if the teie bit in scr is set to 1, a transmit-end interrupt (tei) is requested at this time. ? after the end of serial transmission, the sck pin is held in a constant state. figure 11.17 shows an example of sci transmit operation. transmit direction serial clock serial data tdre tend bit 0 bit 1 bit 7 bit 0 bit 1 bit 6 bit 7 txi interrupt handler writes data in tdr and clears tdre flag to 0 txi request txi request tei request 1 frame figure 11.17 example of sci transmit operation
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 380 of 682 rej09b0353-0300 receiving serial data (synchronous mode): figure 11.18 shows a sample flowchart for receiving serial data and indicates the procedure to follow. when switching from asynchronous mode to synchronous mode, make sure that the orer, per, and fer flags are cleared to 0. if the fer or per flag is set to 1 the rdrf flag will not be set and both transmitting and receiving will be disabled. start receiving read rdrf flag in ssr read receive data from rdr, and clear rdrf flag to 0 in ssr read orer flag in ssr clear re bit to 0 in scr end error handling (continued on next page) 1 4 5 no yes yes no yes 3 1. 2., 3. 4. 5. sci initialization: the receive data function of the rxd pin is selected automatically. receive error handling: if a receive error occurs, read the orer flag in ssr, then after executing the necessary error handling, clear the orer flag to 0. neither transmitting nor receiving can resume while the orer flag remains set to 1. sci status check and receive data read: read ssr, check that the rdrf flag is set to 1, then read receive data from rdr and clear the rdrf flag to 0. notification that the rdrf flag has changed from 0 to 1 can also be given by the rxi interrupt. to continue receiving serial data: check the rdrf flag, read rdr, and clear the rdrf flag to 0 before the msb (bit 7) of the current frame is received. initialize no rdrf = 1? orer = 1? finished receiving? 2 figure 11.18 sample flowchart for serial receiving (1)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 381 of 682 rej09b0353-0300 3 end error handling overrun error handling clear orer flag to 0 in ssr figure 11.18 sample flowchart for serial receiving (2) in receiving, the sci operates as follows. ? the sci synchronizes with serial clock input or output and initializes internally. ? receive data is stored in rsr in order from lsb to msb. after receiving the data, the sci checks that the rdrf flag is 0 so that receive data can be transferred from rsr to rdr. if this check passes, the rdrf flag is set to 1 and the received data is stored in rdr. if the check does not pass (receive error), the sci operates as indicated in table 11.11. if any receive error is detected, the subsequent data transmission/reception is disabled. ? after setting the rdrf flag to 1, if the rie bit is set to 1 in scr, the sci requests a receive- data-full interrupt (rxi). if the orer flag is set to 1 and the rie bit in scr is also set to 1, the sci requests a receive-error interrupt (eri).
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 382 of 682 rej09b0353-0300 figure 11.19 shows an example of sci receive operation. serial clock serial data bit 7 bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 rxi request receive direction rdrf orer rxi interrupt handler reads data in rdr and clears rdrf flag to 0 rxi request overrun error, eri request 1 frame figure 11.19 example of sci receive operation transmitting and receiving serial data simultaneously (synchronous mode): figure 11.20 shows a sample flowchart for transmitting and receiving serial data simultaneously and indicates the procedure to follow.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 383 of 682 rej09b0353-0300 no yes no yes yes no yes no initialize start transmitting and receiving read tdre flag in ssr tdre = 1? write transmit data in tdr and clear tdre flag to 0 in ssr rdrf = 1? read rdrf flag in ssr read receive data from rdr and clear rdrf flag to 0 in ssr read orer flag in ssr orer = 1? end of transmitting and receiving? 1 2 5 3 1. 2. 3. 4. 5. sci initialization: the transmit data output function of the txd pin and receive data input function of the rxd pin are selected, enabling simultaneous transmitting and receiving. sci status check and transmit data write: read ssr, check that the tdre flag is 1, then write transmit data in tdr and clear the tdre flag to 0. error handling note: when switching from transmitting or receiving to simultaneous transmitting and receiving, clear the te and re bits both to 0, then set the te and re bits both to 1. clear te and re bits to 0 in scr end notification that the tdre flag has changed from 0 to 1 can also be given by the txi interrupt. receive error handling: if a receive error occurs, read the orer flag in ssr, then after executing the neces- sary error handling, clear the orer flag to 0. neither transmitting nor receiving can resume while the orer flag remains set to 1. sci status check and receive data read: read ssr, check that the rdrf flag is 1, then read receive data from rdr and clear the rdrf flag to 0. notification that the rdrf flag has changed from 0 to 1 can also be given by the rxi interrupt. to continue transmitting and receiving serial data: check the rdrf flag, read rdr, and clear the rdrf flag to 0 before the msb (bit 7) of the current frame is received. also check that the tdre flag is set to 1, indicat- ing that data can be written, write data in tdr, then clear the tdre flag to 0 before the msb (bit 7) of the current frame is transmitted. 4 figure 11.20 sample flowchart for serial transmitting
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 384 of 682 rej09b0353-0300 11.4 sci interrupts the sci has four interrupt request sources: tei (transmit-end interrupt), eri (receive-error interrupt), rxi (receive-data-full interrupt), and txi (transmit-data-empty interrupt). table 11.12 lists the interrupt sources and indicates their priority. these interrupts can be enabled and disabled by the tie, rie, and teie bits in scr. each interrupt request is sent separately to the interrupt controller. the txi interrupt is requested when the tdre flag is set to 1 in ssr. the tei interrupt is requested when the tend flag is set to 1 in ssr. the rxi interrupt is requested when the rdrf flag is set to 1 in ssr. the eri interrupt is requested when the orer, per, or fer flag is set to 1 in ssr. table 11.12 sci interrupt sources interrupt description priority eri receive error (orer, fer, or per) high rxi receive data register full (rdrf) txi transmit data register empty (tdre) tei transmit end (tend) low
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 385 of 682 rej09b0353-0300 11.5 usage notes note the following points when using the sci. tdr write and tdre flag the tdre flag in ssr is a status flag indicating the loading of transmit data from tdr into tsr. the sci sets the tdre flag to 1 when it transfers data from tdr to tsr. data can be written into tdr regardless of the state of the tdre flag. if new data is written in tdr when the tdre flag is 0, the old data stored in tdr will be lost because this data has not yet been transferred to tsr. before writing transmit data in tdr, be sure to check that the tdre flag is set to 1. simultaneous multiple receive errors table 11.13 indicates the state of ssr status flags when multiple receive errors occur simultaneously. when an overrun error occurs the rsr contents are not transferred to rdr, so receive data is lost. table 11.13 ssr status flags and transfer of receive data ssr status flags rdrf orer fer per receive data transfer rsr rdr receive errors 1100 overrun error 0010 framing error 0001 parity error 1110 overrun error + framing error 1101 overrun error + parity error 0011 framing error + parity error 1111 overrun error + framing error + parity error notes: : receive data is transferred from rsr to rdr. : receive data is not transferred from rsr to rdr.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 386 of 682 rej09b0353-0300 break detection and processing break signals can be detected by reading the rxd pin directly when a framing error (fer) is detected. in the break state the input from the rxd pin consists of all 0s, so the fer flag is set and the parity error flag (per) may also be set. in the break state the sci receiver continues to operate, so if the fer flag is cleared to 0 it will be set to 1 again. sending a break signal when the te bit is cleared to 0 the txd pin becomes an i/o port, the level and direction (input or output) of which are determined by dr and ddr bits. this feature can be used to send a break signal. after the serial transmitter is initialized, the dr value substitutes for the mark state until the te bit is set to 1 (the txd pin function is not selected until the te bit is set to 1). the ddr and dr bits should therefore both be set to 1 beforehand. to send a break signal during serial transmission, clear the dr bit to 0, then clear the te bit to 0. when the te bit is cleared to 0 the transmitter is initialized, regardless of its current state, so the txd pin becomes an input/output port outputting the value 0. receive error flags and transmitter operation (synchronous mode only) when a receive error flag (orer, per, or fer) is set to 1 the sci will not start transmitting, even if the tdre flag is cleared to 0. be sure to clear the receive error flags to 0 when starting to transmit. note that clearing the re bit to 0 does not clear the receive error flags to 0. receive data sampling timing in asynchronous mode and receive margin in asynchronous mode the sci operates on a base clock with 16 times the bit rate frequency. in receiving, the sci synchronizes internally with the fall of the start bit, which it samples on the base clock. receive data is latched at the rising edge of the eighth base clock pulse. see figure 11.21.
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 387 of 682 rej09b0353-0300 internal base clock receive data (rxd) synchronization sampling timing data sampling timing 0 7 15 0 7 15 0 d 0 d 1 8 clocks 16 clocks start bit figure 11.21 receive data sampling timing in asynchronous mode the receive margin in asynchronous mode can therefore be expressed as shown in equation (1). m = | ( 0.5 ? 1 2n ) ? (l ? 0.5) f | d ? 0.5 | n (1 + f) | 100 % ..........(1) m: receive margin ( % ) n: ratio of clock frequency to bit rate (n = 16) d: clock duty cycle (d = 0 to 1.0) l: frame length (l = 9 to 12) f: absolute deviation of clock frequency from equation (1), if f = 0 and d = 0.5 the receive margin is 46.875 % , as given by equation (2). when d = 0.5, f = 0: m = [0.5 ? 1/(2 16)] 100 % = 46.875 % ..........................................................................................(2) this is a theoretical value. a reasonable margin to allow in system design is 20 % to 30 % .
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 388 of 682 rej09b0353-0300 restrictions in synchronous mode when data transmission is performed using an external clock source as the serial clock, an interval of at least 5 states is necessary between clearing the tdre flag in ssr and the start (falling edge) of the first transmit clock pulse corresponding to each frame (figure 11.22). this interval is also necessary when performing continuous transmission. if this condition is not satisfied, an operation error may occur. tdre txd sck t * x0 x1 x2 x3 x4 x5 x6 x7 note: * make sure that t is at least 5 states. t * y0 y1 y2 y3 continuous transmission figure 11.22 transmission in synchronous mode (example)
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 389 of 682 rej09b0353-0300 restrictions when switching from sck pin to port function in synchronous sci 1. problem in operation after setting ddr and dr to 1 and using synchronous sci clock output, when the sck pin is switched to the port function at the end of transmission, a low-level signal is output for one half-cycle before the port output state is established. when switching to the port function by making the following settings while ddr = 1, dr = 1, c/ a = 1, cke1 = 0, cke0 = 0, and te = 1, low-level output occurs for one half-cycle. (1) end of serial data transmission (2) te bit = 0 (3) c/ a bit = 0 ... switchover to port output (4) occurrence of low-level output (see figure 11.23) sck/port data te c/ a cke1 cke0 bit 6 bit 7 (2) te = 0 (3) c/ a = 0 (1) end of transmission (4) low-level output half-cycle low-level output occurs figure 11.23 operation when switching from sck pin function to port pin function
section 11 serial communication interface rev.3.00 mar. 26, 2007 page 390 of 682 rej09b0353-0300 2. usage note the procedure shown below should be used to prevent low-level output when switching from the sck pin function to the port function. as this procedure temporarily places the sck pin in the input state, the sck/port pin should be pulled up beforehand with an external circuit. with ddr = 1, dr = 1, c/ a = 1, cke1 = 0, cke0 = 0, and te = 1, make the following settings in the order shown. (1) end of serial data transmission (2) te bit = 0 (3) cke1 bit = 1 (4) c/ a bit = 0 ... switchover to port output (5) cke1 bit = 0 sck/port data te c/ a cke1 cke0 bit 6 bit 7 (2) te = 0 (5) cke1 = 0 (3) cke1 = 1 (4) c/ a = 0 (1) end of transmission high-level output figure 11.24 operation when switching from sck pin function to port pin function (preventing low-level output)
section 12 smart card interface rev.3.00 mar. 26, 2007 page 391 of 682 rej09b0353-0300 section 12 smart card interface 12.1 overview sci0 supports an ic card (smart card) interface conforming to iso/iec 7816-3 (identification card) as a serial communication interface extension function. switching between the normal serial communication interface and the smart card interface is carried out by means of a register setting. 12.1.1 features features of the smart card interface supported by the h8/3039 group are as follows. ? asynchronous mode ? data length: 8 bits ? parity bit generation and checking ? transmission of error signal (parity error) in receive mode ? error signal detection and automatic data retransmission in transmit mode ? direct convention and inverse convention both supported ? on-chip baud rate generator allows any bit rate to be selected ? three interrupt sources ? three interrupt sources (transmit data empty, receive data full, and transmit/receive error) that can issue requests independently
section 12 smart card interface rev.3.00 mar. 26, 2007 page 392 of 682 rej09b0353-0300 12.1.2 block diagram figure 12.1 shows a block diagram of the smart card interface. bus interface tdr rsr rdr module data bus tsr scmr ssr scr transmission/ reception control brr baud rate generator internal data bus rxd 0 txd 0 sck 0 parity generation parity check clock /4 /16 /64 txi rxi eri smr legend: scmr: rsr: rdr: tsr: tdr: smr: scr: ssr: brr: smart card mode register receive shift register receive data register transmit shift register transmit data register serial mode register serial control register serial status register bit rate register figure 12.1 block diagram of smart card interface
section 12 smart card interface rev.3.00 mar. 26, 2007 page 393 of 682 rej09b0353-0300 12.1.3 pin configuration table 12.1 shows the smart card interface pin configuration. table 12.1 smart card interface pins pin name abbreviation i/o function serial clock pin 0 sck 0 output sci 0 clock output receive data pin 0 rxd 0 input sci 0 receive data input transmit data pin 0 txd 0 output sci 0 transmit data output 12.1.4 register configuration table 12.2 shows the registers used by the smart card interface. details of smr, brr, scr, tdr, and rdr are the same as for the normal sci function: see the register descriptions in section 11, serial communication interface. table 12.2 smart card interface registers address * 1 name abbreviation r/w initial value h'ffb0 serial mode register smr r/w h'00 h'ffb1 bit rate register brr r/w h'ff h'ffb2 serial control register scr r/w h'00 h'ffb3 transmit data register tdr r/w h'ff h'ffb4 serial status register ssr r/(w) * 2 h'84 h'ffb5 receive data register rdr r h'00 h'ffb6 smart card mode register scmr r/w h'f2 notes: 1. lower 16 bits of the address. 2. can only be written with 0 for flag clearing.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 394 of 682 rej09b0353-0300 12.2 register descriptions registers added with the smart card interface and bits for which the function changes are described here. 12.2.1 smart card mode register (scmr) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 ? 1 ? reserved bits smart card data transfer direction selects the serial/parallel conversion format smart card data invert inverts data logic levels smart card interface mode select enables or disables the smart card interface function scmr is an 8-bit readable/writable register that selects the smart card interface function. scmr is initialized to h'f2 by a reset, and in standby mode. bits 7 to 4?reserved: these bits cannot be modified and are always read as 1. bit 3?smart card data transfer direction (sdir): selects the serial/parallel conversion format. bit 3 sdir description 0 tdr contents are transmitted lsb-first (initial value) receive data is stored in rdr lsb-first 1 tdr contents are transmitted msb-first receive data is stored in rdr msb-first
section 12 smart card interface rev.3.00 mar. 26, 2007 page 395 of 682 rej09b0353-0300 bit 2?smart card data invert (sinv): specifies inversion of the data logic level. this function is used together with the sdir bit for communication with an inverse convention card. the sinv bit does not affect the logic level of the parity bit. for parity-related setting procedures, see section 12.3.4, register settings. bit 2 sinv description 0 tdr contents are transmitted as they are (initial value) receive data is stored as it is in rdr 1 tdr contents are inverted before being transmitted receive data is stored in inverted form in rdr bit 1?reserved: this bit cannot be modified and is always read as 1. bit 0?smart card interface mode select (smif): this bit enables or disables the smart card interface function. bit 0 smif description 0 smart card interface function is disabled (initial value) 1 smart card interface function is enabled
section 12 smart card interface rev.3.00 mar. 26, 2007 page 396 of 682 rej09b0353-0300 12.2.2 serial status register (ssr) bit initial value r/w 7 tdre 1 r/(w) * 6 rdrf 0 r/(w) * 5 orer 0 r/(w) * 4 ers 0 r/(w) * 3 per 0 r/(w) * 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r error signal status status flag indicating that an error signal has been received transmit end status flag indicating end of transmission note: * only 0 can be written to bits 7 to 3, to clear these flags. bit 4 of ssr has a different function in smart card interface mode. coupled with this, the setting conditions for bit 2, tend, are also different. bits 7 to 5? operate in the same way as for the normal sci. for details, see section 11.2.7, serial status register (ssr). bit 4?error signal status (ers): in smart card interface mode, bit 4 indicates the status of the error signal sent back from the receiving end in transmission. framing errors are not detected in smart card interface mode. bit 4 ers description 0 indicates normal data transmission, with no error signal returned [clearing conditions] (initial value) ? upon reset, in standby mode, or in module stop mode ? when 0 is written to ers after reading ers = 1 1 indicates that the receiving device sent an error signal reporting a parity error [setting condition] when the low level of the error signal is sampled note: clearing the te bit in scr to 0 does not affect the ers flag, which retains its previous state.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 397 of 682 rej09b0353-0300 bits 3 to 0? operate in the same way as for the normal sci. for details, see section 11.2.7, serial status register (ssr). however, the setting conditions for the tend bit are as shown below. bit 2 tend description 0 transmission is in progress [clearing condition] (initial value) when 0 is written to tdre after reading tdre = 1 1 end of transmission [setting conditions] ? upon reset and in standby mode ? when the te bit in scr is 0 and the ers bit is also 0 ? when tdre = 1 and ers = 0 (normal transmission) 2.5 etu after transmission of a 1-byte serial character note: etu: elementary time unit (time for transfer of 1 bit) 12.3 operation 12.3.1 overview the main functions of the smart card interface are as follows. ? one frame consists of 8-bit and plus a parity bit. ? in transmission, a guard time of at least 2 etu (elementary time unit: the time for transfer of one bit) is left between the end of the parity bit and the start of the next frame. ? if a parity error is detected during reception, a low error signal level is output for one etu period, 10.5 etu after the start bit. ? if the error signal is sampled during transmission, the same data is transmitted automatically after the elapse of 2 etu or longer. ? only asynchronous communication is supported; there is no clocked synchronous communication function.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 398 of 682 rej09b0353-0300 12.3.2 pin connections figure 12.2 shows a schematic diagram of smart card interface related pin connections. in communication with an ic card, since both transmission and reception are carried out on a single data transmission line, the txd 0 pin and rxd 0 pin should be connected with the lsi pin. the data transmission line should be pulled up to the v cc power supply with a resistor. when the clock generated on the smart card interface is used by an ic card, the sck 0 pin output is input to the clk pin of the ic card. no connection is needed if the ic card uses an internal clock. lsi port output is used as the reset signal. other pins must normally be connected to the power supply or ground. h8/3039 group chip connected equipment ic card txd 0 rxd 0 sck 0 px (port) i/o clk rst data line v cc clock line reset line figure 12.2 schematic diagram of smart card interface pin connections note: if an ic card is not connected, and the te and re bits are both set to 1, closed transmission/reception is possible, enabling self-diagnosis to be carried out.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 399 of 682 rej09b0353-0300 12.3.3 data format figure 12.3 shows the smart card interface data format. in reception in this mode, a parity check is carried out on each frame, and if an error is detected an error signal is sent back to the transmitting end, and retransmission of the data is requested. if an error signal is sampled during transmission, the same data is retransmitted. ds d0 d1 d2 d3 d4 d5 d6 d7 dp when there is no parity error transmitting station output ds d0 d1 d2 d3 d4 d5 d6 d7 dp when a parity error occurs transmitting station output de receiving station output start bit data bits parity bit error signal legend: ds: d0 to d7: dp: de: figure 12.3 smart card interface data format
section 12 smart card interface rev.3.00 mar. 26, 2007 page 400 of 682 rej09b0353-0300 the operation sequence is as follows. [1] when the data line is not in use it is in the high-impedance state, and is fixed high with a pull- up resistor. [2] the transmitting station starts a date transfer of one frame. the data frame starts with a start bit (ds, low-level). then 8 data bits (d0 to d7) and a parity bit (dp) follows. [3] with the smart card interface, the data line then returns to the high-impedance state. the data line is pulled high with a pull-up resistor. [4] the receiving station carries out a parity check. if there is no parity error and the data is received normally, the receiving station waits for reception of the next data. if a parity error occurs, however, the receiving station outputs an error signal (de, low-level) to request retransmission of the data. after outputting the error signal for the prescribed length of time, the receiving station places the signal line in the high-impedance state again. the signal line is pulled high again by a pull-up resistor. [5] if the transmitting station does not receive an error signal, it proceeds to transmit the next data frame. if it does receive an error signal, however, it returns to step [2] and retransmits the erroneous data.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 401 of 682 rej09b0353-0300 12.3.4 register settings table 12.3 shows a bit map of the registers used by the smart card interface. bits indicated as 0 or 1 must be set to the value shown. the setting of other bits is described below. table 12.3 smart card interface register settings bit register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 smr 0 0 1 o/ e 1 0 cks1 cks0 brr brr7 brr6 brr5 brr4 brr3 brr2 brr1 brr0 scr tie rie te re 0 0 0 cke0 tdr tdr7 tdr6 tdr5 tdr4 tdr3 tdr2 tdr1 tdr0 ssr tdre rdrf orer ers per tend 0 0 rdr rdr7 rdr6 rdr5 rdr4 rdr3 rdr2 rdr1 rdr0 scmr ???? sdir sinv ? smif note: ? : unused bit. smr setting: the o/ e bit is cleared to 0 if the ic card is of the direct convention type, and set to 1 if of the inverse convention type. bits cks1 and cks0 select the clock source of the on-chip baud rate generator. see section 12.3.5, clock. brr setting: brr is used to set the bit rate. see section 12.3.5, clock, for the method of calculating the value to be set. scr setting: the function of the tie, rie, te, and re bits is the same as for the normal sci. for details, see section 11, serial communication interface. bit cke0 specifies the clock output. set these bits to 0 if a clock is not to be output, or to 1 if a clock is to be output.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 402 of 682 rej09b0353-0300 scmr setting: the sdir bit is cleared to 0 if the ic card is of the direct convention type, and set to 1 if of the inverse convention type. the sinv bit is cleared to 0 if the ic card is of the direct convention type, and set to 1 if of the inverse convention type. the smif bit is set to 1 in the case of the smart card interface. examples of register settings and the waveform of the start character are shown below for the two types of ic card (direct convention and inverse convention). ? direct convention (sdir = sinv = o/ e = 0) ds d0 d1 d2 d3 d4 d5 d6 d7 dp azzazzzaaz (z) (z) state with the direct convention type, the logic 1 level corresponds to state z and the logic 0 level to state a, and transfer is performed in lsb-first order. the start character data above is h'3b. the parity bit is 1 since even parity is stipulated for the smart card. ? inverse convention (sdir = sinv = o/ e = 1) ds d7 d6 d5 d4 d3 d2 d1 d0 dp azzaaaaaaz (z) (z) state with the inverse convention type, the logic 1 level corresponds to state a and the logic 0 level to state z, and transfer is performed in msb-first order. the start character data above is h'3f. the parity bit is 0, corresponding to state z, since even parity is stipulated for the smart card. with the h8/3039 group, inversion specified by the sinv bit applies only to the data bits, d7 to d0. for parity bit inversion, the o/ e bit in smr is set to odd parity mode (the same applies to both transmission and reception).
section 12 smart card interface rev.3.00 mar. 26, 2007 page 403 of 682 rej09b0353-0300 12.3.5 clock only an internal clock generated by the on-chip baud rate generator can be used as the transmit/receive clock for the smart card interface. the bit rate is set with brr and the cks1 and cks0 bits in smr. the formula for calculating the bit rate is as shown below. table 12.5 shows some sample bit rates. if clock output is selected by setting cke0 to 1, a clock with a frequency of 372 times the bit rate is output from the sck 0 pin. b = 1488 2 2n?1 (n + 1) 10 6 where: n = value set in brr (0 n 255) b = bit rate (bit/s) = operating frequency* (mhz) n = see table 12.4 table 12.4 correspondence between n and cks1, cks0 n cks1 cks0 00 0 11 21 0 31 note: * if the gear function is used to divide the system clock frequency, use the divided frequency to calculate the bit rate. the equation above applies directly to 1/1 frequency division. table 12.5 examples of bit rate b (bit/s) for various brr settings (when n = 0) (mhz) n 7.1424 10.00 10.7136 13.00 14.2848 16.00 18.00 0 9600.0 13440.9 14400.0 17473.1 19200.0 21505.4 24193.5 1 4800.0 6720.4 7200.0 8736.6 9600.0 10752.7 12096.8 2 3200.0 4480.3 4800.0 5824.4 6400.0 7168.5 8064.5 note: bit rates are rounded off to one decimal place.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 404 of 682 rej09b0353-0300 the method of calculating the value from the operating frequency and bit rate, on the other hand, is shown below. n is an integer, 0 n 255, and the smaller error is specified. n = 1488 2 2n?1 b 10 6 ? 1 table 12.6 examples of brr settings for bit rate b (bit/s) (when n = 0) (mhz) 7.1424 10.00 10.7136 13.00 14.2848 16.00 18.00 bit/s n error n error n error n error n error n error n error 9600 0 0.00 1 30 1 25 1 8.99 1 0.00 1 12.01 2 15.99 table 12.7 maximum bit rate at various frequencies (smart card interface mode) (mhz) maximum bit rate (bit/s) n n 7.1424 9600 0 0 10.00 13441 0 0 10.7136 14400 0 0 13.00 17473 0 0 14.2848 19200 0 0 16.00 21505 0 0 18.00 24194 0 0 the bit rate error is given by the following formula: error ( % ) = ( 1488 2 2n?1 b (n + 1) 10 6 ? 1) 100
section 12 smart card interface rev.3.00 mar. 26, 2007 page 405 of 682 rej09b0353-0300 12.3.6 data transfer operations initialization before transmitting and receiving data, initialize the sci as described below. initialization is also necessary when switching from transmit mode to receive mode, or vice versa. [1] clear the te and re bits in scr to 0. [2] clear the error flags ers, per, and orer in ssr to 0. [3] set the o/ e bit and cks1 and cks0 bits in smr. clear the c/ a , chr, and mp bits to 0, and set the stop and pe bits to 1. [4] set the smif, sdir, and sinv bits in scmr. when the smif bit is set to 1, the txd 0 and rxd 0 pins are both switched from ports to sci pins, and are placed in the high-impedance state. [5] set the value corresponding to the bit rate in brr. [6] set the cke0 bit in scr. clear the tie, rie, te, re, mpie, teie and cke1 bits to 0. if the cke0 bit is set to 1, the clock is output from the sck 0 pin. [7] wait at least one bit interval, then set the tie, rie, te, and re bits in scr. do not set the te bit and re bit at the same time, except for self-diagnosis.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 406 of 682 rej09b0353-0300 serial data transmission as data transmission in smart card mode involves error signal sampling and retransmission processing, the processing procedure is different from that for the normal sci. figure 12.4 shows an example of the transmission processing flow, and figure 12.5 shows the relation between a transmit operation and the internal registers. [1] perform smart card interface mode initialization as described above in initialization. [2] check that the ers error flag in ssr is cleared to 0. [3] repeat steps [2] and [3] until it can be confirmed that the tend flag in ssr is set to 1. [4] write the transmit data to tdr, clear the tdre flag to 0, and perform the transmit operation. the tend flag is cleared to 0. [5] when transmitting data continuously, go back to step [2]. [6] to end transmission, clear the te bit to 0. with the above processing, interrupt servicing is possible. if transmission ends and the tend flag is set to 1 while the tie bit is set to 1 and interrupt requests are enabled, a transmit data empty interrupt (txi) request will be generated. if an error occurs in transmission and the ers flag is set to 1 while the rie bit is set to 1 and interrupt requests are enabled, a transfer error interrupt (eri) request will be generated. for details, see the following interrupt operations.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 407 of 682 rej09b0353-0300 initialization no yes clear te bit to 0 start transmission start no no no yes yes yes yes no end write data to tdr, and clear tdre flag in ssr to 0 error processing error processing tend = 1? all data transmitted? tend = 1? ers = 0? ers = 0? figure 12.4 example of transmission processing flow
section 12 smart card interface rev.3.00 mar. 26, 2007 page 408 of 682 rej09b0353-0300 tdr tsr (shift register) (1) data write (2) transfer from tdr to tsr (3) serial data output data 1 data 1 data 1 data 1 ; data remains in tdr i/o signal line output in case of normal transmission: tend flag is set in case of transmit error: ers flag is set steps (2) and (3) above are repeated until the tend flag is set data 1 note: when the ers flag is set, it should be cleared until transfer of the last bit (d7 in lsb-first transmission, d0 in msb-first transmission) of the next transfer data has been completed. figure 12.5 relation between transmit operation and internal registers serial data reception data reception in smart card mode uses the same processing procedure as for the normal sci. figure 12.6 shows an example of the transmission processing flow. [1] perform smart card interface mode initialization as described above in initialization. [2] check that the orer flag and per flag in ssr are cleared to 0. if either flag is set, perform the appropriate receive error processing, then clear both the orer and the per flag to 0. [3] repeat steps [2] and [3] until it can be confirmed that the rdrf flag is set to 1. [4] read the receive data from rdr. [5] when receiving data continuously, clear the rdrf flag to 0 and go back to step [2]. [6] to end reception, clear the re bit to 0.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 409 of 682 rej09b0353-0300 initialization read rdr and clear rdrf flag in ssr to 0 clear re bit to 0 start reception start error processing no no no yes yes orer = 0 and per = 0 rdrf = 1? all data received? yes figure 12.6 example of reception processing flow with the above processing, interrupt servicing is possible. if reception ends and the rdrf flag is set to 1 while the rie bit is set to 1 and interrupt requests are enabled, a receive data full interrupt (rxi) request will be generated. if an error occurs in reception and either the orer flag or the per flag is set to 1, a transfer error interrupt (eri) request will be generated. for details, see interrupt operation below. if a parity error occurs during reception and the per is set to 1, the received data is still transferred to rdr, and therefore this data can be read.
section 12 smart card interface rev.3.00 mar. 26, 2007 page 410 of 682 rej09b0353-0300 mode switching operation when switching from receive mode to transmit mode, first confirm that the receive operation has been completed, then start from initialization, clearing re bit to 0 and setting te bit to 1. the rdrf flag or the per and orer flags can be used to check that the receive operation has been completed. when switching from transmit mode to receive mode, first confirm that the transmit operation has been completed, then start from initialization, clearing te bit to 0 and setting re bit to 1. the tend flag can be used to check that the transmit operation has been completed. interrupt operation there are three interrupt sources in smart card interface mode: transmit data empty interrupt (txi) requests, transfer error interrupt (eri) requests, and receive data full interrupt (rxi) requests. the transmit end interrupt (tei) request is not used in this mode. when the tend flag in ssr is set to 1, a txi interrupt request is generated. when the rdrf flag in ssr is set to 1, an rxi interrupt request is generated. when any of flags orer, per, and ers in ssr is set to 1, an eri interrupt request is generated. the relationship between the operating states and interrupt sources is shown in table 12.8. table 12.8 smart card mode operating states and interrupt sources operating state flag mask bit interrupt source transmit mode normal operation tend tie txi error ers rie eri receive mode normal operation rdrf rie rxi error per, orer rie eri
section 12 smart card interface rev.3.00 mar. 26, 2007 page 411 of 682 rej09b0353-0300 12.4 usage note the following points should be noted when using the sci as a smart card interface. receive data sampling timing and reception margin in smart card interface mode in smart card interface mode, the sci operates on a basic clock with a frequency of 372 times the transfer rate. in reception, the sci samples the falling edge of the start bit using the basic clock, and performs internal synchronization. receive data is latched internally at the rising edge of the 186th pulse of the basic clock. this is illustrated in figure 12.7. internal basic clock 372 clocks 186 clocks receive data (rxd) synchro- nization sampling timing d0 d1 data sampling timing 185 371 0 371 185 0 0 start bit figure 12.7 receive data sampling timing in smart card mode
section 12 smart card interface rev.3.00 mar. 26, 2007 page 412 of 682 rej09b0353-0300 thus the reception margin in smart card interface mode is given by the following formula. m = ? (0.5 ? 1 2n ) ? (l ? 0.5) f ? ? d ? 0.5 ? n (1 + f ) ? 100 % where m: reception margin ( % ) n: ratio of bit rate to clock (n = 372) d: clock duty (d = 0 to 1.0) l: frame length (l = 10) f: absolute value of clock frequency deviation assuming values of f = 0 and d = 0.5 in the above formula, the reception margin formula is as follows. when d = 0.5 and f = 0, m = (0.5 ? 1/2 372) 100 % = 49.866 %
section 12 smart card interface rev.3.00 mar. 26, 2007 page 413 of 682 rej09b0353-0300 retransfer operations retransfer operations are performed by the sci in receive mode and transmit mode as described below. ? retransfer operation when sci is in receive mode figure 12.8 illustrates the retransfer operation when the sci is in receive mode. [1] if an error is found when the received parity bit is checked, the per bit in ssr is automatically set to 1. if the rie bit in scr is enabled at this time, an eri interrupt request is generated. the per bit in ssr should be kept cleared to 0 until the next parity bit is sampled. [2] the rdrf bit in ssr is not set for a frame in which an error has occurred. [3] if no error is found when the received parity bit is checked, the per bit in ssr is not set to 1. [4] if no error is found when the received parity bit is checked, the receive operation is judged to have been completed normally, and the rdrf flag in ssr is automatically set to 1. if the rie bit in scr is enabled at this time, an rxi interrupt request is generated. [5] when a normal frame is received, the pin retains the high-impedance state at the timing for error signal transmission. d0 d1 d2 d3 d4 d5 d6 d7 dp de ds d0 d1 d2 d3 d4 d5 d6 d7 dp (de) ds d0 d1 d2 d3 d4 ds transfer frame n+1 retransferred frame nth transfer frame rdrf [1] per [2] [3] [4] figure 12.8 retransfer operation in sci receive mode
section 12 smart card interface rev.3.00 mar. 26, 2007 page 414 of 682 rej09b0353-0300 ? retransfer operation when sci is in transmit mode figure 12.9 illustrates the retransfer operation when the sci is in transmit mode. [6] if an error signal is sent back from the receiving end after transmission of one frame is completed, the ers bit in ssr is set to 1. if the rie bit in scr is enabled at this time, an eri interrupt request is generated. the ers bit in ssr should be kept cleared to 0 until the next parity bit is sampled. [7] the tend bit in ssr is not set for a frame for which an error signal indicating an abnormality is received. [8] if an error signal is not sent back from the receiving end, the ers bit in ssr is not set. [9] if an error signal is not sent back from the receiving end, transmission of one frame, including a retransfer, is judged to have been completed, and the tend bit in ssr is set to 1. if the tie bit in scr is enabled at this time, a txi interrupt request is generated. d0 d1 d2 d3 d4 d5 d6 d7 dp de ds d0 d1 d2 d3 d4 d5 d6 d7 dp (de) ds d0 d1 d2 d3 d4 ds transfer frame n+1 retransferred frame nth transfer frame tdre tend [6] ers transfer to tsr from tdr [7] [9] [8] transfer to tsr from tdr transfer to tsr from tdr figure 12.9 retransfer operation in sci transmit mode
section 13 a/d converter rev.3.00 mar. 26, 2007 page 415 of 682 rej09b0353-0300 section 13 a/d converter 13.1 overview the h8/3039 group includes a 10-bit successive-approximations a/d converter with a selection of up to eight analog input channels. when the a/d converter is not used, it can be halted independently to conserve power. for details see section 17.6, module standby function. 13.1.1 features a/d converter features are listed below. ? 10-bit resolution ? eight input channels ? selectable analog conversion voltage range the analog voltage conversion range can be programmed by input of an analog reference voltage at the av cc pin. ? high-speed conversion conversion time: minimum 7.4 s per channel (with 18 mhz system clock) ? two conversion modes single mode: a/d conversion of one channel scan mode: continuous conversion on one to four channels ? four 16-bit data registers a/d conversion results are transferred for storage into data registers corresponding to the channels. ? sample-and-hold function ? a/d conversion can be externally triggered ? a/d interrupt requested at end of conversion at the end of a/d conversion, an a/d end interrupt (adi) can be requested.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 416 of 682 rej09b0353-0300 13.1.2 block diagram figure 13.1 shows a block diagram of the a/d converter. module data bus bus interface internal data bus addra addrb addrc addrd adcsr adcr successive- approximations register 10-bit d/a av av cc ss analog multi- plexer an an an an an an an an 0 1 2 3 4 5 6 7 sample-and- hold circuit comparator + ? control circuit adtrg /8 /16 adi interrupt legend: adcr: adcsr: addra: addrb: addrc: addrd: a/d control register a/d control/status register a/d data register a a/d data register b a/d data register c a/d data register d figure 13.1 a/d converter block diagram
section 13 a/d converter rev.3.00 mar. 26, 2007 page 417 of 682 rej09b0353-0300 13.1.3 input pins table 13.1 summarizes the a/d converter's input pins. the eight analog input pins are divided into two groups: group 0 (an 0 to an 3 ), and group 1 (an 4 to an 7 ). av cc and av ss are the power supply for the analog circuits in the a/d converter. table 13.1 a/d converter pins pin name abbrevi- ation i/o function analog power supply pin av cc input analog power supply and reference voltage analog ground pin av ss input analog ground and reference voltage analog input pin 0 an 0 input group 0 analog inputs analog input pin 1 an 1 input analog input pin 2 an 2 input analog input pin 3 an 3 input analog input pin 4 an 4 input group 1 analog inputs analog input pin 5 an 5 input analog input pin 6 an 6 input analog input pin 7 an 7 input a/d external trigger input pin adtrg input external trigger input for starting a/d conversion
section 13 a/d converter rev.3.00 mar. 26, 2007 page 418 of 682 rej09b0353-0300 13.1.4 register configuration table 13.2 summarizes the a/d converter's registers. table 13.2 a/d converter registers address * 1 name abbreviation r/w initial value h'ffe0 a/d data register a (high) addrah r h'00 h'ffe1 a/d data register a (low) addral r h'00 h'ffe2 a/d data register b (high) addrbh r h'00 h'ffe3 a/d data register b (low) addrbl r h'00 h'ffe4 a/d data register c (high) addrch r h'00 h'ffe5 a/d data register c (low) addrcl r h'00 h'ffe6 a/d data register d (high) addrdh r h'00 h'ffe7 a/d data register d (low) addrdl r h'00 h'ffe8 a/d control/status register adcsr r/(w) * 2 h'00 h'ffe9 a/d control register adcr r/w h'7f notes: 1. lower 16 bits of the address 2. only 0 can be written in bit 7 to clear the flag.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 419 of 682 rej09b0353-0300 13.2 register descriptions 13.2.1 a/d data registers a to d (addra to addrd) bit addrn initial value 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r a/d conversion data 10-bit data giving an a/d conversion result reserved bits read/write (n = a to d) the four a/d data registers (addra to addrd) are 16-bit read-only registers that store the results of a/d conversion. an a/d conversion produces 10-bit data, which is transferred for storage into the a/d data register corresponding to the selected channel. the upper 8 bits of the result are stored in the upper byte of the a/d data register. the lower 2 bits are stored in the lower byte. bits 5 to 0 of an a/d data register are reserved bits that always read 0. table 13.3 indicates the pairings of analog input channels and a/d data registers. the cpu can always read the a/d data registers. the upper byte can be read directly, but the lower byte is read through a temporary register (temp). for details see section 13.3, cpu interface. the a/d data registers are initialized to h'0000 by a reset and in standby mode. table 13.3 analog input channels and a/d data registers analog input channel group 0 group 1 a/d data register an0 an4 addra an1 an5 addrb an2 an6 addrc an3 an7 addrd
section 13 a/d converter rev.3.00 mar. 26, 2007 page 420 of 682 rej09b0353-0300 13.2.2 a/d control/status register (adcsr) bit initial value read/write 7 adf 0 r/(w) * 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w a/d end flag indicates end of a/d conversion a/d interrupt enable enables and disables a/d end interrupts a/d start starts or stops a/d conversion scan mode selects single mode or scan mode clock select selects the a/d conversion time channel select 2 to 0 these bits select analog input channels note: * only 0 can be written to clear the flag. adcsr is an 8-bit readable/writable register that selects the mode and controls the a/d converter. adcsr is initialized to h'00 by a reset and in standby mode. bit 7?a/d end flag (adf): indicates the end of a/d conversion. bit 7 adf description 0 [clearing condition] (initial value) cleared by reading adf while adf = 1, then writing 0 in adf 1 [setting conditions] ? single mode: a/d conversion ends ? scan mode: a/d conversion ends in all selected channels
section 13 a/d converter rev.3.00 mar. 26, 2007 page 421 of 682 rej09b0353-0300 bit 6?a/d interrupt enable (adie): enables or disables the interrupt (adi) requested at the end of a/d conversion. bit 6 adie description 0 a/d end interrupt request (adi) is disabled (initial value) 1 a/d end interrupt request (adi) is enabled bit 5?a/d start (adst): starts or stops a/d conversion. the adst bit remains set to 1 during a/d conversion. it can also be set to 1 by external trigger input at the adtrg pin. bit 5 adst description 0 a/d conversion is stopped (initial value) 1 single mode: a/d conversion starts; adst is automatically cleared to 0 when conversion ends. scan mode: a/d conversion starts and continues, cycling among the selected channels, until adst is cleared to 0 by software, by a reset, or by a transition to standby mode. bit 4?scan mode (scan): selects single mode or scan mode. for further information on operation in these modes, see section 13.4, operation. clear the adst bit to 0 before switching the conversion mode. bit 4 scan description 0 single mode (initial value) 1 scan mode bit 3?clock select (cks): selects the a/d conversion time. clear the adst bit to 0 before switching the conversion time. bit 3 cks description 0 conversion time = 266 states (maximum) (initial value) 1 conversion time = 134 states (maximum) bits 2 to 0?channel select 2 to 0 (ch2 to ch0): these bits and the scan bit select the analog input channels. clear the adst bit to 0 before changing the channel selection.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 422 of 682 rej09b0353-0300 group selection channel selection description ch2 ch1 ch0 single mode scan mode 000an 0 (initial value) an 0 1an 1 an 0 , an 1 10 an 2 an 0 to an 2 1an 3 an 0 to an 3 100an 4 an 4 1an 5 an 4 , an 5 10 an 6 an 4 to an 6 1an 7 an 4 to an 7 13.2.3 a/d control register (adcr) bit initial value read/write 7 trge 0 r/w 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? trigger enable enables or disables external triggering of a/d conversion reserved bits adcr is an 8-bit readable/writable register that enables or disables external triggering of a/d conversion. adcr is initialized to h'7f by a reset and in standby mode. bit 7?trigger enable (trge): enables or disables external triggering of a/d conversion. bit 7 trge description 0 a/d conversion cannot be externally triggered (initial value) 1 a/d conversion starts at the falling edge of the external trigger signal ( adtrg ) bits 6 to 0?reserved: these bits cannot be modified and are always read as 1.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 423 of 682 rej09b0353-0300 13.3 cpu interface addra to addrd are 16-bit registers, but they are connected to the cpu by an 8-bit data bus. therefore, although the upper byte can be accessed directly by the cpu, the lower byte is read through an 8-bit temporary register (temp). an a/d data register is read as follows. when the upper byte is read, the upper-byte value is transferred directly to the cpu and the lower-byte value is transferred into temp. next, when the lower byte is read, the temp contents are transferred to the cpu. when reading an a/d data register, always read the upper byte before the lower byte. it is possible to read only the upper byte, but if only the lower byte is read, incorrect data may be obtained. figure 13.2 shows the data flow for access to an a/d data register. upper-byte read bus interface module data bus cpu (h'aa) addrnh (h'aa) addrnl (h'40) lower-byte read bus interface module data bus cpu (h'40) addrnh (h'aa) addrnl (h'40) temp (h'40) temp (h'40) (n = a to d) (n = a to d) figure 13.2 a/d data register access operation (reading h'aa40)
section 13 a/d converter rev.3.00 mar. 26, 2007 page 424 of 682 rej09b0353-0300 13.4 operation the a/d converter operates by successive approximations with 10-bit resolution. it has two operating modes: single mode and scan mode. 13.4.1 single mode (scan = 0) single mode should be selected when only one a/d conversion on one channel is required. a/d conversion starts when the adst bit is set to 1 by software, or by external trigger input. the adst bit remains set to 1 during a/d conversion and is automatically cleared to 0 when conversion ends. when conversion ends the adf bit is set to 1. if the adie bit is also set to 1, an adi interrupt is requested at this time. to clear the adf flag to 0, first read adcsr, then write 0 in adf. when the mode or analog input channel must be switched during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1 to start a/d conversion again. the adst bit can be set at the same time as the mode or channel is changed. typical operations when channel 1 (an 1 ) is selected in single mode are described next. figure 13.3 shows a timing diagram for this example. 1. single mode is selected (scan = 0), input channel an 1 is selected (ch2 = ch1 = 0, ch0 = 1), the a/d interrupt is enabled (adie = 1), and a/d conversion is started (adst = 1). 2. when a/d conversion is completed, the result is transferred into addrb. at the same time the adf flag is set to 1, the adst bit is cleared to 0, and the a/d converter becomes idle. 3. since adf = 1 and adie = 1, an adi interrupt is requested. 4. the a/d interrupt handling routine starts. 5. the routine reads adcsr, then writes 0 in the adf flag. 6. the routine reads and processes the conversion result (addrb). 7. execution of the a/d interrupt handling routine ends. after that, if the adst bit is set to 1, a/d conversion starts again and steps 2 to 7 are repeated.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 425 of 682 rej09b0353-0300 adie adst adf state of channel 0 (an ) set set set clear clear idle idle idle idle idle a/d conversion (1) a/d conversion (2) idle read conversion result a/d conversion result (1) read conversion result a/d conversion result (2) vertical arrows ( ) indicate instructions executed by software. 0 1 2 3 a/d conversion starts * * * * * addra addrb addrc addrd state of channel 1 (an ) state of channel 2 (an ) state of channel 3 (an ) note: * figure 13.3 example of a/d converter operation (single mode, channel 1 selected)
section 13 a/d converter rev.3.00 mar. 26, 2007 page 426 of 682 rej09b0353-0300 13.4.2 scan mode (scan = 1) scan mode is useful for monitoring analog inputs in a group of one or more channels. when the adst bit is set to 1 by software or external trigger input, a/d conversion starts on the first channel in the group (an 0 when ch2 = 0, an 4 when ch2 = 1). when two or more channels are selected, after conversion of the first channel ends, conversion of the second channel (an 1 or an 5 ) starts immediately. a/d conversion continues cyclically on the selected channels until the adst bit is cleared to 0. the conversion results are transferred for storage into the a/d data registers corresponding to the channels. when the mode or analog input channel selection must be changed during analog conversion, to prevent incorrect operation, first clear the adst bit to 0 in adcsr to halt a/d conversion. after making the necessary changes, set the adst bit to 1. a/d conversion will start again from the first channel in the group. the adst bit can be set at the same time as the mode or channel selection is changed. typical operations when three channels in group 0 (an 0 to an 2 ) are selected in scan mode are described next. figure 13.4 shows a timing diagram for this example. 1. scan mode is selected (scan = 1), scan group 0 is selected (ch2 = 0), analog input channels an 0 to an 2 are selected (ch1 = 1, ch0 = 0), and a/d conversion is started (adst = 1). 2. when a/d conversion of the first channel (an 0 ) is completed, the result is transferred into addra. next, conversion of the second channel (an 1 ) starts automatically. 3. conversion proceeds in the same way through the third channel (an 2 ). 4. when conversion of all selected channels (an 0 to an 2 ) is completed, the adf flag is set to 1 and conversion of the first channel (an 0 ) starts again. if the adie bit is set to 1, an adi interrupt is requested at this time. 5. steps 2 to 4 are repeated as long as the adst bit remains set to 1. when the adst bit is cleared to 0, a/d conversion stops. after that, if the adst bit is set to 1, a/d conversion starts again from the first channel (an 0 ).
section 13 a/d converter rev.3.00 mar. 26, 2007 page 427 of 682 rej09b0353-0300 adst adf state of channel 0 (an ) 0 1 2 3 continuous a/d conversion set clear * 1 clear * 1 idle a/d conversion (1) idle idle idle a/d conversion (4) idle a/d conversion (2) idle a/d conversion (5) idle a/d conversion (3) idle idle transfer a/d conversion result (1) a/d conversion result (4) a/d conversion result (2) a/d conversion result (3) 1. 2. a/d conversion time notes: * 2 * 1 addra addrb addrc addrd state of channel 1 (an ) state of channel 2 (an ) state of channel 3 (an ) vertical arrows ( ) indicate instructions executed by software. data currently being converted is ignored. figure 13.4 example of a/d converter operation (scan mode, channels an 0 to an 2 selected)
section 13 a/d converter rev.3.00 mar. 26, 2007 page 428 of 682 rej09b0353-0300 13.4.3 input sampling and a/d conversion time the a/d converter has a built-in sample-and-hold circuit. the a/d converter samples the analog input at a time t d after the adst bit is set to 1, then starts conversion. figure 13.5 shows the a/d conversion timing. table 13.4 indicates the a/d conversion time. as indicated in figure 13.5, the a/d conversion time includes t d and the input sampling time. the length of t d varies depending on the timing of the write access to adcsr. the total conversion time therefore varies within the ranges indicated in table 13.4. in scan mode, the values given in table 13.4 apply to the first conversion. in the second and subsequent conversions the conversion time is fixed at 256 states when cks = 0 or 128 states when cks = 1. address bus write signal input sampling timing adf (1) (2) t d t spl t conv legend: (1): (2): t : t : t : d spl conv adcsr write cycle adcsr address synchronization delay input sampling time a/d conversion time figure 13.5 a/d conversion timing
section 13 a/d converter rev.3.00 mar. 26, 2007 page 429 of 682 rej09b0353-0300 table 13.4 a/d conversion time (single mode) cks = 0 cks = 1 symbol min typ max min typ max synchronization delay t d 10 ? 17 6 ? 9 input sampling time t spl ? 63 ?? 31 ? a/d conversion time t conv 259 ? 266 131 ? 134 note: values in the table are numbers of states. 13.4.4 external trigger input timing a/d conversion can be externally triggered. when the trge bit is set to 1 in adcr, external trigger input is enabled at the adtrg pin. a high-to-low transition at the adtrg pin sets the adst bit to 1 in adcsr, starting a/d conversion. other operations, in both single and scan modes, are the same as if the adst bit had been set to 1 by software. figure 13.6 shows the timing. adtrg internal trigger signal adst a/d conversion figure 13.6 external trigger input timing
section 13 a/d converter rev.3.00 mar. 26, 2007 page 430 of 682 rej09b0353-0300 13.5 interrupts the a/d converter generates an interrupt (adi) at the end of a/d conversion. the adi interrupt request can be enabled or disabled by the adie bit in adcsr. 13.6 usage notes the following points should be noted when using the a/d converter. setting range of analog power supply and other pins (1) analog input voltage range the voltage applied to analog input pins an 0 to an 7 during a/d conversion should be in the range av ss ann av cc . (2) relation between av cc , av ss and v cc , v ss as the relationship between av cc , av ss and v cc , v ss , set av ss = v ss . if the a/d converter is not used, the av cc and av ss pins must on no account be left open. if conditions (1) and (2) above are not met, the reliability of the device may be adversely affected. notes on board design in board design, digital circuitry and analog circuitry should be as mutually isolated as possible, and layout in which digital circuit signal lines and analog circuit signal lines cross or are in close proximity should be avoided as far as possible. failure to do so may result in incorrect operation of the analog circuitry due to inductance, adversely affecting a/d conversion values. also, digital circuitry must be isolated from the analog input signals (an 0 to an 7 ), and analog power supply and reference voltage (av cc ) by the analog ground (av ss ). also, the analog ground (av ss ) should be connected at one point to a stable digital ground (v ss ) on the board. notes on noise countermeasures a protection circuit connected to prevent damage due to an abnormal voltage such as an excessive surge at the analog input pins (an 0 to an 7 ) and analog power supply (av cc ) should be connected between av cc and av ss as shown in figure 13.7. also, the bypass capacitors connected to av cc and the filter capacitor connected to an 0 to an 7 must be connected to av ss .
section 13 a/d converter rev.3.00 mar. 26, 2007 page 431 of 682 rej09b0353-0300 if a filter capacitor is connected as shown in figure 13.7, the input currents at the analog input pins (an 0 to an 7 ) are averaged, and so an error may arise. also, when a/d conversion is performed frequently, as in scan mode, if the current charged and discharged by the capacitance of the sample-and-hold circuit in the a/d converter exceeds the current input via the input impedance (r in ), an error will arise in the analog input pin voltage. therefore careful consideration is required when deciding the circuit constants. av cc * 1 an 0 to an 7 av ss notes: values are reference values. 1. 2. r in : input impedance r in * 2 100 ? 0.1 f 0.01 f 10 f figure 13.7 example of analog input protection circuit table 13.5 analog pin specifications item min max unit analog input capacitance ? 20 pf permissible signal source impedance ? 10 * k ? note: * when v cc = 4.0 v to 5.5 v and 12 mhz
section 13 a/d converter rev.3.00 mar. 26, 2007 page 432 of 682 rej09b0353-0300 20 pf to a/d converter an 0 to an 7 10 k ? note: values are reference values. figure 13.8 analog input pin equivalent circuit a/d conversion precision definitions h8/3039 group a/d conversion precision definitions are given below. ? resolution the number of a/d converter digital output codes ? offset error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from the minimum voltage value b'0000000000 (h'000) to b'0000000001 (h'001) (see figure 13.10). ? full-scale error the deviation of the analog input voltage value from the ideal a/d conversion characteristic when the digital output changes from b'1111111110 (h'3fe) to b'1111111111 (h'3ff) (see figure 13.10). ? quantization error the deviation inherent in the a/d converter, given by 1/2 lsb (see figure 13.9). ? nonlinearity error the error with respect to the ideal a/d conversion characteristic between the zero voltage and the full-scale voltage. does not include the offset error, full-scale error, or quantization error. ? absolute precision the deviation between the digital value and the analog input value. includes the offset error, full-scale error, quantization error, and nonlinearity error.
section 13 a/d converter rev.3.00 mar. 26, 2007 page 433 of 682 rej09b0353-0300 111 110 101 100 011 010 001 000 fs quantization error digital output ideal a/d conversion characteristic analog input voltage 1 8 2 8 3 8 5 8 4 8 6 8 7 8 figure 13.9 a/d conversion precision definitions (1) fs offset error nonlinearity error actual a/d conversion characteristic analog input voltage digital output ideal a/d conversion characteristic full-scale error figure 13.10 a/d conversion precision definitions (2)
section 13 a/d converter rev.3.00 mar. 26, 2007 page 434 of 682 rej09b0353-0300 permissible signal source impedance h8/3039 group analog input is designed so that conversion precision is guaranteed for an input signal for which the signal source impedance is 10 k ? or less. this specification is provided to enable the a/d converter's sample-and-hold circuit input capacitance to be charged within the sampling time; if the sensor output impedance exceeds 10 k ? , charging may be insufficient and it may not be possible to guarantee the a/d conversion precision. when converting in the single mode, if a large capacitance is provided externally, the input load will essentially comprise only the internal input resistance of 10 k ? , and the signal source impedance is ignored. however, since a low-pass filter effect is obtained in this case, it may not be possible to follow an analog signal with a large differential coefficient (e.g., voltage regulation 5 mv/s or greater). when converting a high-speed analog signal and when performing conversion in the scan mode, a low-impedance buffer should be inserted. influences on absolute precision adding capacitance results in coupling with gnd, and therefore noise in gnd may adversely affect absolute precision. be sure to make the connection to an electrically stable gnd such as av ss . care is also required to insure that filter circuits do not communicate with digital signals on the mounting board, thus acting as antennas. a/d converter equivalent circuit h8/3039 group 20 pf c in = 15 pf 10 k ? up to 10 k ? low-pass filter c up to 0.1 f sensor output impedance sensor input note: values are reference values. figure 13.11 example of analog input circuit
section 14 ram rev.3.00 mar. 26, 2007 page 435 of 682 rej09b0353-0300 section 14 ram 14.1 overview the h8/3039 has 4 kbytes of on-chip static ram, h8/3038 has 2 kbytes, h8/3037 has 1 kbyte, and h8/3036 has 512 bytes. the ram is connected to the cpu by a 16-bit data bus. the cpu accesses both byte data and word data in two states, making the ram suitable for rapid data transfer. the ram enable bit (rame) in the system control register (syscr) can enable or disable the on-chip ram. table 14.1 shows the address of the on-chip ram in each operating mode. table 14.1 the address of the on-chip ram in each operating mode mode h8/3039 (4 kbytes) h8/3038 (2 kbytes) h8/3037 (1k byte) h8/3036 (512 bytes) modes 1, 5, 7 h'fef10 to h'fff0f h'ff710 to h'fff0f h'ffb10 to h'fff0f h'ffd10 to h'fff0f mode 3 h'ffef10 to h'ffff0f h'fff710 to h'ffff0f h'fffb10 to h'ffff0f h'fffd10 to h'ffff0f mode 6 h'f710 to h'ff0f h'f710 to h'ff0f h'fb10 to h'ff0f h'fd10 to h'ff0f
section 14 ram rev.3.00 mar. 26, 2007 page 436 of 682 rej09b0353-0300 14.1.1 block diagram figure 14.1 shows a block diagram of the on-chip ram. h'fef10 * h'fef12 * h'fff0e * h'fef11 * h'fef13 * h'fff0f * bus interface syscr on-chip ram even addresses odd addresses legend: syscr: system control register note: * lower 20 bits of the address internal data bus (upper 8 bits) internal data bus (lower 8 bits) figure 14.1 ram block diagram (h8/3039 in modes 1, 5 and 7) 14.1.2 register configuration the on-chip ram is controlled by the system control register (syscr). table 14.2 gives the address and initial value of syscr. table 14.2 ram control register address * name abbreviation r/w initial value h'fff2 system control register syscr r/w h'0b note: * lower 16 bits of the address
section 14 ram rev.3.00 mar. 26, 2007 page 437 of 682 rej09b0353-0300 14.2 system control register (syscr) bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ue 1 r/w 2 nmieg 0 r/w 1 ? 1 ? 0 rame 1 r/w software standby standby timer select 2 to 0 user bit enable nmi edge select reserved bit ram enable bit enables or disables on-chip ram one function of syscr is to enable or disable access to the on-chip ram. the on-chip ram is enabled or disabled by the rame bit in syscr. for details about the other bits, see section 3.3, system control register (syscr). bit 0?ram enable (rame): enables or disables the on-chip ram. the rame bit is initialized at the rising edge of the input at the res pin. it is not initialized in software standby mode. bit 0 rame description 0 on-chip ram is disabled 1 on-chip ram is enabled (initial value)
section 14 ram rev.3.00 mar. 26, 2007 page 438 of 682 rej09b0353-0300 14.3 operation when the rame bit is set to 1, the on-chip ram is enabled. this lsi can access the on-chip ram when addressing the addresses shown in table 14.1 in each operation mode. when the rame bit is cleared to 0 in modes 1, 3, and 5 (expanded modes), external address space is accessed. when the rame bit is cleared to 0 in modes 6 and 7 (single-chip modes), the on-chip ram is not accessed. read operation always reads h'ff and disables writing. the on-chip ram is connected to the cpu by a 16-bit wide data bus and can be read and written on a byte or a word basis. byte data can be accessed in two states using the higher 8 bits of the data bus. word data beginning from an even address can be accessed in two states using the 16-bit data bus.
section 15 rom rev.3.00 mar. 26, 2007 page 439 of 682 rej09b0353-0300 section 15 rom 15.1 overview the h8/3039 has 128 kbytes of on-chip rom (flash memory or mask rom), the h8/3038 has 64 kbytes, the h8/3037 has 32 kbytes and h8/3036 has 16 kbytes. the rom is connected to the cpu by a 16-bit data bus. the cpu accesses both byte and word data in two states, enabling rapid data transfer. the mode pins (md 2 to md 0 ) can be set to enable or disable the on-chip rom. see table 15.1. the on-chip flash memory product (h8/3039f-ztat) can be erased and programmed on-board as well as with a general-purpose prom programmer. table 15.1 operating mode and rom mode pins mode md 2 md 1 md 0 on-chip rom mode 1 (1-mbyte expanded mode with on-chip rom disabled) 0 0 1 disabled (external address area) mode 2 (1-mbyte expanded mode with on-chip rom disabled) * 010 mode 3 (16-mbyte expanded mode with on-chip rom disabled) 011 mode 4 (16-mbyte expanded mode with on-chip rom disabled) * 100 mode 5 (16-mbyte expanded mode with on-chip rom enabled) 1 0 1 enabled mode 6 (single-chip normal mode) 1 1 0 mode 7 (single-chip advanced mode) 1 1 1 note: * modes 2 and 4 cannot be used with this lsi. do not set the mode pin to mode 2 or 4.
section 15 rom rev.3.00 mar. 26, 2007 page 440 of 682 rej09b0353-0300 15.2 overview of flash memory 15.2.1 features the features of the flash memory are summarized below. ? four flash memory operating modes ? program mode ? erase mode ? program-verify mode ? erase-verify mode ? programming/erase methods the flash memory is programmed 32 bytes at a time. erasing is performed by block erase. the block to be erased can be specified by setting the corresponding bit. there are block areas of 32 kbytes 3 blocks, 28 kbytes 1 block, and 1 kbyte 4 blocks. ? programming/erase times the flash memory programming time is 10 ms (typ.) for simultaneous 32-byte programming, equivalent to 300 s (typ.) per byte, and the erase time is 100 ms (typ.) per block. ? reprogramming capability the flash memory can be reprogrammed up to 100 times. ? on-board programming modes there are two modes in which flash memory can be programmed/erased/verified on-board: ? boot mode ? user program mode ? automatic bit rate adjustment with data transfer in boot mode, the this lsi's bit rate can be automatically adjusted to match the transfer bit rate of the host (9600 bps and 4800 bps). ? flash memory emulation by ram part of the ram area can be overlapped onto flash memory, to emulate flash memory updates in real time. ? prom mode flash memory can be programmed/erased in prom mode, using a prom programmer, as well as in on-board programming mode. ? protect modes there are three protect modes, hardware, software, and error protect, which allow protected status to be designated for flash memory program/erase/verify operations.
section 15 rom rev.3.00 mar. 26, 2007 page 441 of 682 rej09b0353-0300 15.2.2 block diagram figure 15.1 shows a block diagram of the flash memory. bus interface/controller on-chip flash memory (128 kbytes) operating mode internal data bus (upper 8 bits) internal data bus (lower 8 bits) fwe pin * 1 mode pins flmcr * 2 ebr * 2 ramcr * 2 flmsr * 2 h'00000 h'00002 h'00001 h'00003 h'1fffe h'1ffff even address odd address legend: flmcr: flash memory control register ebr: erase block register ramcr: ram control register flmsr: flash memory status register notes: 1. functions as the fwe pin in the flash memory versions and as the reso pin in the mask rom versions. 2. the registers that control the flash memory versions (flmcr, ebr, ramcr, and flmsr) are used in the flash memory versions only. they are not provided in the mask rom versions. reading the corresponding addresses in a mask rom version will always return 1s, and writes to these addresses are disabled. h'1fffc h'1fffd figure 15.1 block diagram of flash memory
section 15 rom rev.3.00 mar. 26, 2007 page 442 of 682 rej09b0353-0300 15.2.3 pin configuration the flash memory is controlled by means of the pins shown in table 15.2. table 15.2 flash memory pins pin name abbreviation i/o function reset res input reset flash write enable fwe * input flash program/erase protection by hardware mode 2 md 2 input sets this lsi operating mode mode 1 md 1 input sets this lsi operating mode mode 0 md 0 input sets this lsi operating mode transmit data txd 1 output serial transmit data output receive data rxd 1 input serial receive data input notes: the transmit data and receive data pins are used in boot mode. * in the mask rom versions, the fwe pin functions as the reso pin. 15.2.4 register configuration the registers used to control the on-chip flash memory when enabled are shown in table 15.3. table 15.3 flash memory registers register name abbreviation r/w initial value address * 1 flash memory control register flmcr r/w h'00 * 2 h'ff40 erase block register ebr r/w h'00 h'ff42 ram control register ramcr r/w h'f1 h'ff47 flash memory status register flmsr r h'7f h'ff4d notes: 1. lower 16 bits of the address. 2. when a high level is input to the fwe pin, the initial value is h'80. the registers in table 15.3 are used in the flash memory versions only. reading the corresponding addresses in a mask rom version will always return 1s, and writes to these addresses are disabled.
section 15 rom rev.3.00 mar. 26, 2007 page 443 of 682 rej09b0353-0300 15.3 register descriptions 15.3.1 flash memory control register (flmcr) flmcr is an 8-bit register used for flash memory operating mode control. program-verify mode or erase-verify mode is entered by setting swe to 1 when fwe = 1. program mode is entered by setting swe to 1 when fwe = 1, then setting the psu bit, and finally setting the p bit. erase mode is entered by setting swe to 1 when fwe = 1, then setting the esu bit, and finally setting the e bit. flmcr is initialized by a reset, and in hardware standby mode and software standby mode. its initial value is h'80 when a high level is input to the fwe pin, and h'00 when a low level is input. in mode 6 the fwe pin must be fixed low, as flash memory on-board programming is not supported. therefore, bits in this register cannot be set to 1 in mode 6. when on-chip flash memory is disabled, a read will return h'00, and writes are invalid. when setting bits 6 to 0 in this register to 1, each bit should be set individually. writes to the esu, psu, ev and pv bits in flmcr are enabled only when fwe = 1 and swe = 1; writes to the e bit only when fwe = 1, swe = 1, and esu = 1; and writes to the p bit only when fwe = 1, swe = 1, and psu = 1.
section 15 rom rev.3.00 mar. 26, 2007 page 444 of 682 rej09b0353-0300 bit modes 1 to 4, and 6 7 0 r 0 r 0 r 0 r 0 r 0 r 0 r 0 r initial value read/write initial value read/write modes 5 and 7 1/0 r 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w fwe ev 6543210 esu psu pv e p program setup prepares for a transition to program mode. erase setup prepares for a transition to erase mode. erase mode designates transition to or exit from erase mode program mode designates transition to or exit from program mode program-verify mode designates transition to or exit from program-verify mode erase-verify mode designates transition to or exit from erase-verify mode flash write enable bit sets hardware protection against flash memory programming/erasing. software write enable bit enables or disables the flash memory. swe bit 7?flash write enable bit (fwe): sets hardware protection against flash memory programming/erasing. when using this bit, refer to section 15.9, notes on flash memory programming/erasing. bit 7 fwe description 0 when a low level is input to the fwe pin (hardware-protected state) 1 when a high level is input to the fwe pin
section 15 rom rev.3.00 mar. 26, 2007 page 445 of 682 rej09b0353-0300 bit 6?software write enable bit (swe)* 1 * 2 : this bit enables/disables flash memory programming/erasing. this bit should be set before setting flmcr bits 5 to 0, and ebr bits 7 to 0. do not set the esu, psu, ev, pv, e, or p bits at the same time. bit 6 swe description 0 program/erase disabled (initial value) 1 program/erase enabled [setting condition] when fwe = 1 bit 5?erase setup bit (esu)* 1 : prepares for a transition to erase mode. do not set the swe, psu, ev, pv, e, or p bit at the same time. bit 5 esu description 0 erase setup cleared (initial value) 1 erase setup [setting condition] when fwe = 1, and swe = 1 bit 4?program setup bit (psu)* 1 : prepares for a transition to program mode. do not set the swe, esu, ev, pv, e, or p bit at the same time. bit 4 psu description 0 program setup cleared (initial value) 1 program setup [setting condition] when fwe = 1, and swe = 1
section 15 rom rev.3.00 mar. 26, 2007 page 446 of 682 rej09b0353-0300 bit 3?erase-verify (ev)* 1 : selects erase-verify mode transition or clearing. do not set the swe, esu, psu, pv, e, or p bit at the same time. bit 3 ev description 0 erase-verify mode cleared (initial value) 1 transition to erase-verify mode [setting condition] when fwe = 1, and swe = 1 bit 2?program-verify (pv)* 1 : selects program-verify mode transition or clearing. do not set the swe, esu, psu, ev, e, or p bit at the same time. bit 2 pv description 0 program-verify mode cleared (initial value) 1 transition to program-verify mode [setting condition] when fwe = 1, and swe = 1 bit 1?erase (e)* 1 * 3 : selects erase mode transition or clearing. do not set the swe, esu, psu, ev, pv, or p bit at the same time. bit 1 e description 0 erase mode cleared (initial value) 1 transition to erase mode [setting condition] when fwe = 1, swe = 1, and esu = 1
section 15 rom rev.3.00 mar. 26, 2007 page 447 of 682 rej09b0353-0300 bit 0?program (p)* 1 * 3 : selects program mode transition or clearing. do not set the swe, esu, psu, ev, pv, or e bit at the same time. bit 0 p description 0 program mode cleared (initial value) 1 transition to program mode [setting condition] when fwe = 1, swe = 1, and psu = 1 notes: 1. do not set two or more bits at the same time. do not turn off v cc when a bit is set. 2. do not set/clear the swe bit simultaneously with other bits (esu, psu, ev, pv, e, p). 3. set the p and e bits according to the program and erase algorithms shown in section 15.5, programming/erasing flash memory. for the usage precautions, see section 15.9, notes on flash memory programming/erasing. 15.3.2 erase block register (ebr) ebr is an 8-bit register that designates the flash memory block for erasure. ebr is initialized to h'00 by a reset, in hardware standby mode, or software standby mode, when a high level is not input to the fwe terminal, or when the flmcr swe bit is 0 when a high level is applied to the fwe terminal. when a bit is set in ebr, the corresponding block can be erased. other blocks are erase - protected. the blocks are erased block by block. therefore, set only one bit in ebr; do not set bits in ebr to erase two or more blocks at the same time. each bit in ebr cannot be set until the swe bit in flmcr is set. the flash memory block configuration is shown in table 15.4. to erase all the blocks, erase each block sequentially. this lsi does not support the on-board programming mode in mode 6, so bits in this register cannot be set to 1 in mode 6.
section 15 rom rev.3.00 mar. 26, 2007 page 448 of 682 rej09b0353-0300 bit 7 eb7 eb3 6543210 eb5 eb4 eb2 eb1 eb0 eb6 modes 1 to 4, and 6 0 r 0 r 0 r 0 r 0 r 0 r 0 r 0 r initial value read/write initial value read/write modes 5 and 7 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w bits 7 to 0?block 7 to 0 (eb7 to eb0): these bits select blocks (eb7 to eb0) to be erased. bits 7 to 0 eb7 to eb0 description 0 block eb7 to eb0 is not selected. (initial value) 1 block eb7 to eb0 is selected. note: set each bit of ebr to h'00 except when erasing. table 15.4 flash memory erase blocks block (size) address eb0 (1 kbyte) h'00000 to h'003ff eb1 (1 kbyte) h'00400 to h'007ff eb2 (1 kbyte) h'00800 to h'00bff eb3 (1 kbyte) h'00c00 to h'00fff eb4 (28 kbytes) h'01000 to h'07fff eb5 (32 kbytes) h'08000 to h'0ffff eb6 (32 kbytes) h'10000 to h'17fff eb7 (32 kbytes) h'18000 to h'1ffff
section 15 rom rev.3.00 mar. 26, 2007 page 449 of 682 rej09b0353-0300 15.3.3 ram control register (ramcr) ramcr selects the ram area used when emulating real-time reprogramming of the flash memory. bit 7 ? rams 6543210 ??? ram2 ram1 ? ram2/1 this bit is used with bit 3 to set the ram area. ram select this bit is used with bits 2 and 1 to set the ram area. reserved bits reserved bit modes 1 to 4 1 ? 1 ? 1 ? 1 ? 0 r 0 r 0 r 1 ? initial value read/write initial value read/write modes 5 to 7 1 ? 1 ? 1 ? 1 ? 0 r/w * 0 r/w * 0 r/w * 1 ? note: * cannot be set to 1 in mode 6. bits 7 to 4?reserved: these bits cannot be modified and are always read as 1. bit 3?ram select (rams): is used with bits 2 to 1 to reassign an area to ram (see table 15.5). the initial setting for this bit is 0 in modes 5, 6, and 7 (internal flash memory enabled) and programming is enabled.* in modes other than 5 to 7, 0 is always read and writing is disabled. it is initialized by a reset and in hardware standby mode. it is not initialized in software standby mode. when bit 3 is set, all flash-memory blocks are protected from programming and erasing. bits 2 to 1?ram2 to ram1: these bits are used with bit 3 to reassign an area to ram (see table 15.5). the initial setting for this bit is 0 in modes 5, 6, and 7 (internal flash memory enabled) and programming is enabled.* in modes other than 5 to 7, 0 is always read and writing is disabled. they are initialized by a reset and in hardware standby mode. they are not initialized in software standby mode.
section 15 rom rev.3.00 mar. 26, 2007 page 450 of 682 rej09b0353-0300 bit 0?reserved: this bit cannot be modified and is always read as 1. note: * flash memory emulation by ram is not supported for mode 6 (single chip normal mode), so programming is possible, but do not set 1. when performing flash memory emulation by ram, the rame bit in syscr must be set to 1. table 15.5 ram area reassignment bit 3 bit 2 bit 1 ram area rams ram2 ram1 ram emulation state h'fff800 to h'fffbff 0 0/1 0/1 no emulation h'000000 to h'0003ff 1 0 0 mapping ram h'000400 to h'0007ff 1 0 1 h'000800 to h'000bff 1 1 0 h'000c00 to h'000fff 1 1 1 rom block eb0 ? eb3 (h'00000 ? h'00fff) rom area ram area h'00000 h'00400 h'00800 h'00c00 eb0 eb1 eb3 real ram h'003ff h'007ff h'00bff h'00fff h'fef10 h'ff800 h'ffc00 h'ff7ff h'ffbff h'fff0f mapping ram eb2 ram overlap area (h'ff800 ? h'ffbff) ram selection area rom selection area figure 15.2 example of overlap rom area and ram area
section 15 rom rev.3.00 mar. 26, 2007 page 451 of 682 rej09b0353-0300 15.3.4 flash memory status register (flmsr) the flash memory status register (flmsr) detects flash memory errors. bit initial value read/write 7 0 fler ? 6543210 111 1111 r ? ? ????? ?? ? ??? reserved bits flash memory error status flag indicating that an error was detected during programming or erasing bit 7?flash memory error (fler): indicates that an error occurred while flash memory was being programmed or erased. when bit 7 is set, flash memory is placed in an error-protect mode. bit 7 fler description 0 flash memory program/erase protection (error protection * 1 ) is disabled (initial value) [clearing condition] wdt reset, reset by res pin, or hardware standby mode 1 an error has occurred during flash memory programming/erasing flash memory program/erase protection (error protection * 1 ) is enabled [setting conditions] 1. flash memory was read * 2 while being programmed or erased (including vector or instruction fetch, but not including reading of a ram area overlapped onto flash memory). 2. a hardware exception-handling sequence (other than a reset, invalid instruction, trap instruction, or zero-divide exception) was executed just before programming or erasing. * 3 3. the sleep instruction (including software standby mode) was executed during programming or erasing. notes: 1. for details, see section 15.6.3, error protection. 2. the read data has undetermined values. 3. before stack and vector read by exception handling. bits 6 to 0?reserved: these bits cannot be modified and are always read as 1.
section 15 rom rev.3.00 mar. 26, 2007 page 452 of 682 rej09b0353-0300 15.4 on-board programming modes when pins are set to on-board programming mode, program/erase/verify operations can be performed on the on-chip flash memory. there are two on-board programming modes: boot mode and user program mode. the pin settings for transition to each of these modes are shown in table 15.6. in mode 6 (on-chip rom enabled) in this lsi, the boot mode and user program mode cannot be used. for the notes on fwe pin set/reset, see section 15.9, notes on flash memory programming/erasing. table 15.6 setting on-board programming modes mode fwe md 2 md 1 md 0 notes boot mode mode 5 1 * 1 0 * 2 010: v il mode 7 0 * 2 111: v ih user program mode mode 5 1 0 1 mode 7 1 1 1 notes: 1. for the high level input timing, see items (6) and (7) of notes on using the boot mode. 2. in the boot mode, the md 2 setting becomes inverted input. in the boot mode, the mode control register (mdcr) can be used to monitor the status of modes 5 and 7 in the same way as in the normal mode.
section 15 rom rev.3.00 mar. 26, 2007 page 453 of 682 rej09b0353-0300 on-board programming modes ? boot mode flash memory this chip ram host programming control program sci application program (old version) programming control program new application program programming control program new application program flash memory this chip ram host sci application program (old version) boot program area new application program flash memory this chip ram host sci flash memory erase boot program flash memory this chip program execution state ram host sci new application program boot program 1. initial state the flash memory is in the erased state when the device is shipped. the description here applies to the case where the old program version or data is being rewritten. the user should prepare the programming control program and new application program beforehand in the host. 2. programming control program transfer when boot mode is entered, the boot program in this chip (originally incorporated in the chip) is started, an sci communication check is carried out, and the boot program required for flash memory erasing is automatically transferred to the ram boot program area. 3. flash memory initialization the erase program in the boot program area (in ram) is executed, and the flash memory is initialized (to h'ff). in boot mode, entire flash memory erasure is performed, without regard to blocks. 4. writing new application program the programming control program transferred from the host to ram by sci communication is executed, and the new application program in the host is written into the flash memory. boot program boot program boot program area programming control program figure 15.3 boot mode
section 15 rom rev.3.00 mar. 26, 2007 page 454 of 682 rej09b0353-0300 ? user program mode flash memory this chip ram host programming/ erase control program sci boot program new application program flash memory this chip ram host sci new application program flash memory this chip ram host sci flash memory erase boot program new application program flash memory this chip program execution state ram host sci boot program boot program application program (old version) new application program 1. initial state (1) the program that will transfer the programming/ erase control program to on-chip ram should be written into the flash memory by the user beforehand. (2) the programming/erase control program should be prepared in the host or in the flash memory. 2. programming/erase control program transfer when the fwe pin is driven high, user software confirms this fact, executes the transfer program in the flash memory, and transfers the programming/erase control program to ram. 3. flash memory initialization the programming/erase program in ram is executed, and the flash memory is initialized (to h'ff). erasing can be performed in block units, but not in byte units. 4. writing new application program next, the new application program in the host is written into the erased flash memory blocks. do not write to unerased blocks. programming/ erase control program programming/ erase control program programming/ erase control program application program (old version) transfer program fwe assessment program transfer program fwe assessment program transfer program transfer program figure 15.4 user program mode (example)
section 15 rom rev.3.00 mar. 26, 2007 page 455 of 682 rej09b0353-0300 15.4.1 boot mode when boot mode is used, the flash memory programming control program must be prepared in the host beforehand. the channel 1 sci to be used is set to asynchronous mode. in reset start, after setting this lsi pin to the boot mode, start the microcomputer boot program, measure the low period of the data sent from the host, and select the bit rate register (brr) value beforehand. then enable reception of the user program from the outside using the serial communication interface (sci) on this lsi, and write the received user program to on-chip ram. after the program has been stored the end of writing, execution branches to the top address (h'ff300) of the on-chip ram, execute the program written on the on-chip ram, and enable flash memory program/erase. the system configuration in boot mode is shown in figure 15.5, and the boot program mode execution procedure in figure 15.6. rxd 1 txd 1 sci1 this lsi flash memory write data reception verify data transmission host on-chip ram figure 15.5 system configuration in boot mode
section 15 rom rev.3.00 mar. 26, 2007 page 456 of 682 rej09b0353-0300 after branching to the ram boot program area (h'fef10 to h'ff2ff), this lsi checks the data in the flashmemory user area. after sending h'aa, this lsi branches to the ram area (h'ff300) and executes the user program transferred to the ram. transfer end byte count n = 0? all data = h'ff? yes yes no no 1 2 3 4 5 6 7 1 2 3 4 5 6 8 7 8 9 erase all blocks of flash memory. * 3 set this lsi to the boot mode and reset starts the lsi. set the host to the prescribed bit rate (4800, 9600) and consecutively send h'00 data in 8-bit data, 1 stop bit format. this lsi repeatedly measures the rxd1 pin low period and calculates the asynchronous communication bit rate at which the host performs transfer. at the end of sci bit rate adjustment, this lsi sends one byte of h'00 data to signal the end of adjustment. check if the host normally received the one byte bit rate adjustment end signal sent from this lsi and sent one byte of h'55 data. after h'55 is sent, the host receives h'aa and sends the byte count of the user program that is transferred to this lsi. send the 2-byte count in upper byte and lower byte order. then sequentially send the program set by the user. this lsi sequentially sends (echo back) each byte of the received byte count and user program to the host as verification data. this lsi sequentially writes the received user program to the on-chip ram area (h'ff300 ? h'ffeff). before executing the transferred user program, this lsi checks if data was written to flash memory after control branched to the ram boot program area (h'fef10 ? h'ff2ff). if data was already written to flash memory, all the blocks are erased. 9 notes: 1. 2. 3. after sending h'aa, this lsi branches to the on-chip ram area (h'ff300) and executes the user program written to that area. the ram area that can be used by the user is 3.0 kbytes. set the transfer byte count to within 3.0 kbytes. always send the 2-byte transfer byte count in upper byte and lower byte order. transfer byte count example: for 256 bytes (h'0100), upper byte h'01, lower byte h'00. set the part that controls the user program flash memory at the program according to the flash memory programming/erase algorithms described later. when a memory cell malfunctions and cannot be erased, this lsi sends one h'ff byte as an erase error and stops the erase operation and subsequent operations. this lsi transfers the user program to ram. * 2 start set pins to boot program mode and execute reset-start host transfers data (h'00) continuously at prescribed bit rate this lsi measures low period of h'00 data transmitted by host this lsi calculates bit rate and sets value in bit rate register after bit rate adjustment, this lsi transmits one byte of h'00 data to host to indicate end of adjustment host confirms normal reception of bit rate adjustment end indication (h'00), and transmits one byte of h'55 data after receiving h'55, this lsi sends h'aa and receives two bytes of the byte count (n) of the program transferred to the on-chip ram. * 1 this lsi calculates the remaining number of bytes to be sent (n = n ? 1). figure 15.6 boot mode execution procedure
section 15 rom rev.3.00 mar. 26, 2007 page 457 of 682 rej09b0353-0300 automatic sci bit rate adjustment start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 low period (9 bits) measured (h'00 data) high period (1 or more bits) figure 15.7 measuring the low period of the communication data from the host when boot mode is initiated, this lsi measures the low period of the asynchronous sci communication data (h'00) transmitted continuously from the host (figure 15.7). the sci transmit/receive format should be set as follows: 8-bit data, 1 stop bit, no parity. this lsi calculates the bit rate of the transmission from the host from the measured low period, and transmits one h'00 byte to the host to indicate the end of bit rate adjustment. the host should confirm that this adjustment end indication (h'00) has been received normally, and transmit one h'55 byte to the lsi. if reception cannot be performed normally, initiate boot mode again (reset), and repeat the above operations. depending on the host's transmission bit rate and the system clock frequency of this lsi, there will be a discrepancy between the bit rates of the host and the lsi. to ensure correct sci operation, the host's transfer bit rate should be set to 4800 and 9600 bps* 1 . table 15.7 shows typical host transfer bit rates and system clock frequencies for which automatic adjustment of this lsi bit rate is possible. the boot program should be executed within this system clock range* 2 . table 15.7 system clock frequencies for which automatic adjustment of this lsi bit rate is possible host bit rate (bps) system clock frequency for which automatic adjustment of this lsi bit rate is possible (mhz) 9600 8 to 18 4800 4 to 18 notes: 1. the host bit rate settings are 4800 and 9600bps only. do not use any other setting. 2. this lsi may automatically adjusts the bit rate except for bit rate and system clock combinations as shown in table 15.7. however, the bit rate of the host and this lsi will be different and subsequent transfers will not be carried out normally. therefore, always execute the boot mode within the range of the bit rate and system clock combinations shown in table 15.7.
section 15 rom rev.3.00 mar. 26, 2007 page 458 of 682 rej09b0353-0300 on-chip ram area divisions in boot mode in boot mode, the ram area is divided into an area used by the boot program and an area to which the user program is transferred via the sci, as shown in figure 15.8. the boot program area can be used when a transition is made to the execution state for the user program transferred to ram. h'fef10 h'fff0f user program transfer area boot program area h'ff300 notes: 1. the boot program area cannot be used until a transition is made to the execution state for the user program transferred to ram. note also that the boot program remains in this ram area even after control branches to the user program. 2. when flash memory emulation is performed using ram, part of the user program transfer area (h'ff800 to h'ffbff) is used as an area for carrying out emulation, and therefore user program transfer must not be performed to this area. (approximately 1kbyte) (approximately 3.0 kbytes) figure 15.8 ram areas in boot mode notes on using the boot mode (1) when this lsi comes out of reset in boot mode, it measures the low period the input at the sci's rxd 1 pin. the reset should end with rxd 1 high. after the reset ends, it takes about 100 states for this lsi to get ready to measure the low period of the rxd 1 input. (2) if any data has been written to the flash memory (if all data is not h'ff), all flash memory blocks are erased when this mode is executed. therefore, boot mode should be used for initial on-board programming, or for forced recovery if the program to be activated in user program mode is accidentally erased and user program mode cannot be executed, for example. (3) interrupts cannot be used during programming or erasing of flash memory.
section 15 rom rev.3.00 mar. 26, 2007 page 459 of 682 rej09b0353-0300 (4) the rxd 1 and txd 1 pins should be pulled up on the board. (5) this lsi terminates transmit and receive operations by the on-chip sci(channel 1) (by clearing the re and te bits in serial control register (scr)) before branching to the user program. however, the adjusted bit rate is held in the bit rate register (brr). at this time, the txd 1 pin is in the high level output state (p9ddr p9 1 ddr=1, p9dr p9 1 dr=1). before branching to the user program the value of the general registers in the cpu are also undefined. therefore, the general registers must be initialized immediately after control branches to the user program. since the stack pointer (sp) is implicitly used during subroutine call, etc., a stack area must be specified for use by the user program. there are no other internal i/o registers in which the initial value is changed. (6) transition to the boot mode executes a reset-start of this lsi after setting the md 0 to md 2 and fwe pins according to the mode setting conditions shown in table 15.6. at this time, this lsi latches the status of the mode pin inside the microcomputer to maintain the boot mode status at the reset clear (startup with low high) timing* 1 . to clear boot mode, it is necessary to drive the fwe pin low during the reset, and then execute reset release* 1 . the following points must be noted: (a) before making a transition from the boot mode to the regular mode, the microcomputer boot mode must be reset by reset input via the res pin. at this time, the res pin must be hold at low level for at least 20 system clock.* 3 (b) do not change the input levels at the mode pins (md 2 to md 0 ) or the fwe pin while in boot mode. when making a mode transition, first enter the reset state by inputting a low level to the res pin. when a watchdog timer reset was generated in the boot mode, the microcomputer mode is not reset and the on-chip boot program is restarted regardless of the state of the mode pin. (c) do not input low level to the fwe pin while the boot program is executing and when programming/erasing flash memory.* 2 (7) if the mode pin and fwe pin input levels are changed from 0 v to v cc or from v cc to 0v during a reset (while a low level is being input to the res pin), the microcomputer's operating mode will change. therefore, since the state of the address dual port and bus control output signals ( as , rd , wr ) changes, use of these pins as output signals during reset must be disabled outside the microcomputer. notes: 1. the mode pin and fwe pin input must satisfy the mode programming setup time (t mds ) relative to the reset clear timing. 2. for notes on fwe pin high/low, see section 15.9, notes on flash memory programming/erasing.
section 15 rom rev.3.00 mar. 26, 2007 page 460 of 682 rej09b0353-0300 3. see section 4.2.2, reset sequence and 15.9, notes on flash memory programming/erasing. with the mask rom version of the h8/3039, h8/3038, h8/3037, and h8/3036, the minimum reset period during operation is 10 system clocks. however, the flash memory versions of the h8/3039 requires a minimum of 20 system clocks. 15.4.2 user program mode when set to the user program mode, this lsi can erase and program its flash memory by executing a user program. therefore, on-chip flash memory on-board programming can be performed by providing a means of controlling fwe and supplying the write data on the board and providing a write program in a part of the program area. to select this mode, set the lsi to on-chip rom enable modes 5 and 7 and apply a high level to the fwe pin. in this mode, the peripheral functions, other than flash memory, are performed the same as in modes 5 and 7. since the flash memory cannot be read while it is being programmed/erased, place a programming program on external memory, or transfer the programming program to ram area, and execute it in the ram. in mode 6, do not program/erase the flash memory. when setting mode 6, always input low level to the fwe pin. figure 15.9 shows the procedure for executing when transferred to on-chip ram. during reset start, starting from the user program mode is possible.
section 15 rom rev.3.00 mar. 26, 2007 page 461 of 682 rej09b0353-0300 fwe = high (user program mode) branch to program in ram. transfer on-board programming program to ram. reset start md 2 ? md 0 = 101, 111 execute on-board programming program in ram (flash memory reprogramming). input low level to fwe after swe bit clear (user program mode exit) execute user application program in flash memory. the user writes a program that executes steps 3 to 8 in advance as shown below . sets the mode pin to an on-chip rom enable mode (mode 5 or 7). starts the cpu via reset. (the cpu can also be started from the user program mode by setting the fwe pin to high level during reset; that is, during the period the res pin is a low level.) transfers the on-board programming program to ram. branches to the program in ram. sets the fwe pin to a high level. * (switches to user program mode.) after confirming that the fwe pin is a high level, executes the on-board programming program in ram. this reprograms the user application program in flash memory. at the end of reprograming, clears the swe bit, and exits the user program mode by switching the fwe pin from a high level to a low level. * branches to, and executes, the user application program reprogrammed in flash memory. 1 2 3 4 5 6 7 8 for notes on fwe pin high/low, see section 15.9, notes on flash memory programming/erasing. note: * 1 2 3 4 5 6 7 8 figure 15.9 user program mode execution procedure (example) note: normally do not apply a high level to the fwe pin. to prevent erroneous programming or erasing in the event of program runaway, etc., apply a high level to the fwe pin only when programming/erasing flash memory (including flash memory emulation by ram). if program runaway, etc. causes overprogramming or overerasing of flash memory, the memory cells will not operate normally. also, while a high level is applied to the fwe pin, the watchdog timer should be activated to prevent overprogramming or overerasing due to program runaway, etc. in mode 6, do not reprogram flash memory. when setting mode 6, always set the fwe pin to a low level.
section 15 rom rev.3.00 mar. 26, 2007 page 462 of 682 rej09b0353-0300 15.5 programming/erasing flash memory a software method, using the cpu, is employed to program and erase flash memory in the on- board programming modes. there are four flash memory operating modes: program mode, erase mode, program-verify mode, and erase-verify mode. transitions to these modes can be made by setting the psu, esu, p, e, pv, and ev bits in flmcr. for a description of state transition by flmcr bit setting, see figure 15.10. the flash memory cannot be read while being programmed or erased. therefore, the program that controls flash memory programming/erasing (the programming control program) should be located and executed in on-chip ram or external memory. for the programming/erasing notes, see section 15.9, notes on flash memory programming/erasing. for the wait time after each bit in flmcr is set or cleared, see section 18.2.5, flash memory characteristics. notes: 1. operation is not guaranteed if setting/resetting of the swe, esu, psu, ev, pv, e, and p bits in flmcr is executed by a program in flash memory. 2. when programming or erasing, set the fwe pin input level to the high level, and set fwe to 1. (programming/erasing will not be executed if fwe = 0).
section 15 rom rev.3.00 mar. 26, 2007 page 463 of 682 rej09b0353-0300 normal mode on-board programming mode software reprogramming disable state erase setup state erase mode programming mode erase-verify mode program setup state program-verify mode esu = 1 esu = 0 swe = 1 swe = 0 fwe = 1 fwe = 0 * 1 * 2 * 3 ev = 1 ev = 0 e = 1 e = 0 pv = 1 pv = 0 p = 1 p = 0 psu =1 psu = 0 software reprogramming enable state notes: : normal mode : on-board programming mode 1. do not make a state transition by setting or clearing two or more bits at the same time. 2. after transition from the erase mode to the erase setup state, do not make a transition to the erase mode without going through the software reprogramming enable state. 3. after transition from the programming mode to the program setup state, do not switch to the programming mode without going through the software reprogramming enable state. figure 15.10 state transition by setting of each bit of flmcr 15.5.1 program mode follow the procedure shown in the program/program-verify flowchart in figure 15.11 to write data or programs to flash memory. performing program operations according to this flowchart will enable data or programs to be written to flash memory without subjecting the device to voltage stress or sacrificing program data reliability. programming should be carried out 32 bytes at a time. for the wait time (x, y, z, , , , , ) after setting or clearing each bit in the flash memory control register (flmcr) and the maximum programming count (n), see table 18.15. following the elapse of (x) s or more after the swe bit is set to 1 in flash memory control register (flmcr), 32-byte program data is stored in the program data area and reprogram data area, and the 32-byte data in the reprogram data area written consecutively to the write addresses. (the lower 8 bits of the first address written to must be h'00, h'20, h'40, h'60, h'80, h'a0, h'c0, or h'e0.) 32 consecutive byte data transfers are performed. the program address and program data are latched in the flash memory. a 32-byte data transfer must be performed even if writing fewer than 32 bytes; in this case, h'ff data must be written to the extra addresses.
section 15 rom rev.3.00 mar. 26, 2007 page 464 of 682 rej09b0353-0300 next, the watchdog timer (wdt) is set to prevent overprogramming due to program runaway, etc. set a value greater than (y + z + + ?) s as the wdt overflow period. preparation for entering program mode (program setup) is performed next by setting the psu bit in flmcr. the operating mode is then switched to program mode by setting the p bit in flmcr after the elapse of at least (y) s. the time while the p bit is set is the flash memory programming time. make a program setting so that the time for one programming operation is within the range of (z) s. the wait time after p bit setting must be changed according to the number of reprogramming loops. for details, see section 18.2.5, flash memory characteristics. 15.5.2 program-verify mode in program-verify mode, the data written in program mode is read to check whether it has been correctly written in the flash memory. clear the p bit in flmcr, then wait for at least ( ) s before clearing the psu bit to exit program mode. after exiting program mode, the watchdog timer setting is also cleared. then the operating mode is switched to program-verify mode by setting the pv bit in flmcr. before reading in program-verify mode, a dummy write of h'ff data should be made to the addresses to be read. the dummy write should be executed after the elapse of ( ) s or more. when the flash memory is read in this state (verify data is read in 16-bit units), the data at the latched address is read. wait at least ( ) s after the dummy write before performing this read operation. next, the originally written data is compared with the verify data, and reprogram data is computed (see figure 15.11) and transferred to ram. after verification of 32 bytes of data has been completed, exit program- verify mode, wait for at least ( ) s, then determine whether 32-byte programming has finished. if reprogramming is necessary, set program mode again, and repeat the program/program-verify sequence as before. however, ensure that the program/program-verify sequence is not repeated more than (n) times on the same bits. note: a 32-byte area to store program data and a 32-byte area to store reprogram data are required in ram.
section 15 rom rev.3.00 mar. 26, 2007 page 465 of 682 rej09b0353-0300 start end of programming set swe bit in flmcr wait (x) s consecutively write 32-byte data in reprogram data area in ram to flash memory programming operation counter n 1 set psu bit in flmcr wait (y) s set p bit in flmcr wait (z) s clear p bit in flmcr wait ( ) s clear psu bit in flmcr wait ( ) s set pv bit in flmcr wait ( ) s store 32-byte write data in write data area and reprogram data area enable wdt start of programming ng no ok * 6 * 6 * 5 * 4 * 6 * 3 * 6 * 6 * 6 * 1 * 2 * 6 * 6 * 7 end of programming * 6 disable wdt set verify start address programming end flag 0 h'ff dummy write to verify address wait ( ) s read verify data transfer computation result to reprogram data area increment verify address reprogram data computation clear pv bit in flmcr wait ( ) s clear swe bit in flmcr programming end flag 1 (unfinished) programming ok? 32-byte data verification completed? programming end flag = 0? programming failure yes yes yes clear swe bit in flmcr n > n? n n + 1 notes: 1. programming should be performed in the erased state. (perform 32-byte programming on memory after all 32 bytes have been erased.) 2. data transfer is performed by byte transfer (word transfer is not possible), with the write start address at a 32-byte boundary. the lower 8 bits of the first address written to must be h'00, h'20, h'40, h'60, h'80, h'a0, h'c0, or h'e0. a 32-byte data transfer must be performed even if writing fewer than 32 bytes; in this case, h'ff data must be written to the extra addresses. 3. verify data is read in 16-bit (word) units. (byte-unit reading is also possible.) 4. reprogram data is determined by the computation shown in the table below (comparison of data stored in the program data area with verify data). programming of reprogram data 0 bits is executed in the next programming loop. therefore, even bits for which programming has been completed will be programmed again if the result of the subsequent verify operation is ng. 5. an area for storing write data (32 bytes) and an area for storing reprogram data (32 bytes) must be provided in ram. the contents of the latter are rewritten in accordance with the reprogramming data computation. 6. the values of x, y, z, , , , , , and n are shown in section 18.2.5, flash memory characteristics. 7. the value of z depends on the number of reprogramming loops (n). details are given in section 18.2.5, flash memory characteristics. no write verify reprogram data data data comments 0 0 1 programming completed 0 1 0 programming incomplete; reprogram 1 0 1 ? 1 1 1 still in erased state; no action ram program data storage area (32 bytes) reprogram data storage area (32 bytes) no reprogram figure 15.11 program/program-verify flowchart
section 15 rom rev.3.00 mar. 26, 2007 page 466 of 682 rej09b0353-0300 15.5.3 erase mode flash memory erasing should be performed block by block following the procedure shown in the erase/erase-verify flowchart (single-block erase) shown in figure 15.12. for the wait time (x, y, z, ? ) s as the wdt overflow period. preparation for entering erase mode (erase setup) is performed next by setting the esu bit in flmcr. the operating mode is then switched to erase mode by setting the e bit in flmcr after the elapse of at least (y) s. the time during which the e bit is set is the flash memory erase time. ensure that the erase time does not exceed (z) ms. note: with flash memory erasing, preprogramming (setting all data in the memory to be erased to "0") is not necessary before starting the erase procedure. 15.5.4 erase-verify mode in erase-verify mode, data is read after memory has been erased to check whether it has been correctly erased. after the elapse of the fixed erase time, clear the e bit in flmcr, then wait for at least (
section 15 rom rev.3.00 mar. 26, 2007 page 467 of 682 rej09b0353-0300 end of erasing start set swe bit in flmcr wait (x) s set e bit in flmcr wait (z) ms erase counter n 1 set ebr enable wdt * 2 * 4 * 5 * 2 * 2 * 2 * 2 set block start address to verify address * 2 * 2 * 2 * 2 * 2 * 3 start of erase clear e bit in flmcr wait ( ) s clear esu bit in flmcr wait ( ) s set ev bit in flmcr wait ( ) s h'ff dummy write to verify address wait ( ) s read verify data clear ev bit in flmcr wait ( ) s clear ev bit in flmcr wait ( ) s clear swe bit in flmcr disable wdt end of erase * 1 verify data = h'ffff? last address of block? erase failure clear swe bit in flmcr n > n? no no yes yes yes notes: 1. preprogramming (setting erase block data to all 0s) is not necessary. 2. the values of x, y, z, , , , , , and n are shown in section 18.2.5, flash memory characteristics. 3. verify data is read in 16-bit (word) units. (byte-unit reading is also possible.) 4. set only one bit in ebr two or more bits must not be set simultaneously. 5. erasing is performed in block units. to erase multiple blocks, each block must be erased in turn. set esu bit in flmcr wait (y) s n n + 1 increment verify address no re-erase figure 15.12 erase/erase-verify flowchart (single-block erasing)
section 15 rom rev.3.00 mar. 26, 2007 page 468 of 682 rej09b0353-0300 15.6 flash memory protection there are three kinds of flash memory program/erase protection: hardware protection, software protection, and error protection. 15.6.1 hardware protection hardware protection refers to a state in which programming/erasing of flash memory is forcibly disabled or aborted. hardware protection is reset by settings in the flash memory control register (flmcr) and erase block register (ebr). in the case of error protection, the p bit and e bit can be set, but a transition is not made to program mode or erase mode. (see table 15.8.)
section 15 rom rev.3.00 mar. 26, 2007 page 469 of 682 rej09b0353-0300 table 15.8 hardware protection function item description program erase verify * 1 fwe pin protection ? when a low level is input to the fwe pin, flmcr and ebr are initialized, and the program/erase-protected state is entered. * 4 no * 2 no * 3 no reset/standby protection ? in a reset (including a wdt overflow reset) and in standby mode, flmcr and ebr are initialized, and the program/erase-protected state is entered. ? in a reset via the res pin, the reset state is not entered unless the res pin is held low until oscillation stabilizes after powering on (the minimum oscillation stabilization time is 20ms). in the case of a reset during operation, hold the res pin low for at least 20 system clock cycles. * 5 no no * 3 no error protection ? when a microcomputer operation error (error generation (fler=1)) was detected while flash memory was being programmed/erased, error protection is enabled. at this time, the flmcr and ebr settings are held, but programming/erasing is aborted at the time the error was generated. error protection is released only by a reset via the res pin or a wdt reset, or in the hardware standby mode. no no * 3 yes notes: 1. two modes: program-verify and erase-verify. 2. the ram area that overlapped flash memory is deleted. 3. all blocks become unerasable and specification by block is impossible. 4. for more information, see section 15.9, notes on flash memory programming/erasing. 5. see sections 4.2.2, reset sequence and 15.9, notes on flash memory programming/erasing. this lsi requires a minimum reset time during operation of 20 system clocks.
section 15 rom rev.3.00 mar. 26, 2007 page 470 of 682 rej09b0353-0300 15.6.2 software protection software protection can be implemented by setting the rams bit in ram control register (ramcr) and erase block register (ebr). when software protection is in effect, setting the p or e bit in flash memory control register (flmcr) does not cause a transition to program mode or erase mode. (see table 15.9.) table 15.9 software protection function item description program erase verify * 1 emulation protection * 2 setting the rams bit in ramcr sets the program/erase-protected state for all blocks. no * 2 no * 3 yes block specification protection erase protection can be set for individual blocks by settings in erase block register (ebr). * 4 however, program protection is disabled. setting ebr to h'00 places all blocks in the erase-protected state. ? no yes notes: 1. two modes: program-verify mode and erase-verify mode. 2. programming to the ram area that overlaps flash memory is possible. 3. all blocks become unerasable, and specification by block is impossible. 4. set h'00 in the ebr bits, except for erase.
section 15 rom rev.3.00 mar. 26, 2007 page 471 of 682 rej09b0353-0300 15.6.3 error protection in error protection, an error is detected when this lsi runaway occurs during flash memory programming/erasing* 1 , or operation is not performed in accordance with the program/erase algorithm, and the program/erase operation is aborted. aborting the program/erase operation prevents damage to the flash memory due to overprogramming or overerasing. if the lsi malfunctions during flash memory programming/erasing, the fler bit* 2 is set to 1 in flash memory status register (flmsr) and the error protection state is entered. the flmcr and ebr settings* 3 are retained, but program mode or erase mode is aborted at the point at which the error occurred. when 1 is set in the fler bit, transition to the program mode or erase mode cannot be made even by setting the p and e bits in flmcr. however, pv and ev bit in flmcr setting is enabled, and a transition can be made to verify mode. error protection is released only by a reset via the res pin or a wdt reset, or in the hardware standby mode. figure 15.13 shows the flash memory state transition diagram. notes: 1. this is the state in which the p or e bit in flmcr is set to 1. in this state, nmi input is disabled. for more information, see section 15.6.4, nmi input disable conditions. 2. for a detailed description of the fler bits setting conditions, see section 15.3.4, flash memory status register (flmsr). 3. data can be written to flmcr and ebr. however, when transition to the software standby mode was made in the error protection state, the registers are initialized.
section 15 rom rev.3.00 mar. 26, 2007 page 472 of 682 rej09b0353-0300 memory read enable verify-read enable programming enable erasing enable rd: vf: pr: er: legend: memory read disabled verify-read disabled programming disabled erasing disabled registers (flmcr, ebr) initialize state rd : vf : pr : er : init: error occurrence p=1 or e=1 p = 0 and e = 0 error occurre nce (software sta ndby mode) reset or hardware standby mode reset, hardwa re standby mo de, or software sta ndby mode reset release, hardware sta ndby mode release , and software standby mode release reset or hardware standby mode reset or hardware standby mode program mode erase mode memory read verify mode reset or standby mode (hardware protection) error protection mode error protection mode (software standby mode) software standby mode software standby mode release rd vf pr er fler = 0 rd vf pr er fler = 0 rd vf pr er fler = 1 rd vf pr er init fler = 1 rd vf pr er init fler = 0 figure 15.13 flash memory state transitions (when high level apply to fwe pin in modes 5 and 7 (on-chip rom enabled)) the error protection function is disabled for errors other than the fler bit set conditions. if considerable time elapses up to transit to this protection state, the flash memory may already be damaged. as a result, this function cannot completely protect the flash memory against damage. therefore, to prevent such erroneous operation, operation must be carried out correctly in according with the program/erase algorithms in the state that flash write enable (fwe) is set. in addition, the operation must be always carried out correctly by supervising microcomputer errors inside and outside the chip with the watchdog timer, etc. at transition to this protection mode, the flash memory may be erroneously programmed or erased, or its abort may result in incomplete
section 15 rom rev.3.00 mar. 26, 2007 page 473 of 682 rej09b0353-0300 programming and erasing. in such cases, always forcibly return (reprogram) by boot mode. however, overprogramming and overerasing may prevent the boot mode from starting normally. 15.6.4 nmi input disable conditions while flash memory is being programmed/erased and the boot program is executing in the boot mode (however, period up to branching to on-chip ram area)* 1 , nmi input is disabled because the programming/erasing operations have priority. this is done to avoid the following operation states: 1. generation of an nmi input during programming/erasing violates the program/erase algorithms and normal operation can not longer be assured. 2. vector-read cannot be carried out normally* 2 during nmi exception handling during programming/erasing and the microcomputer runs away as a result. 3. if an nmi input is generated during boot program execution, the normal boot mode sequence cannot be executed. therefore, this lsi has conditions that exceptionally disable nmi inputs only in the on-board programming mode. however, this does not assure normal programming/erasing and microcomputer operation. thus, in the fwe application state, all requests, including nmi, inside and outside the microcomputer, exception handling, and bus release must be restricted. nmi inputs are also disabled in the error protection state and the state that holds the p or e bit in flmcr during flash memory emulation by ram. notes: 1. indicates the period up to branching to the on-chip ram boot program area (h'fef10 to h'ff2ff). (this branch occurs immediately after user program transfer was completed.) therefore, after branching to ram area, nmi input is enabled in states other than the program/erase state. thus, interrupt requests inside and outside the microcomputer must be disabled until initial writing by user program (writing of vector table and nmi processing program, etc.) is completed. 2. in this case, vector read is not performed normally for the following two reasons: a. the correct value cannot be read even by reading the flash memory during programming/erasing. (value is undefined.) b. if a value has not yet been written to the nmi vector table, nmi exception handling will not be performed correctly.
section 15 rom rev.3.00 mar. 26, 2007 page 474 of 682 rej09b0353-0300 15.7 flash memory emulation by ram erasing and programming the flash memory takes time, which can make it difficult to tune parameters and other data in real time. in this case, overlapping part (h'ff800 to h'ffbff) of ram onto a small block area of flash memory can be performed to emulate real-time reprogramming of flash memory. this ram reassignment is performed using bits 3 to 1 in the ram control register (ramcr). after the ram area change, two areas can be accessed: the overlapped flash memory area and the original ram area (h'ff800 to h'ffbff). for a description of the ramcr and ram area setting procedure, see section 15.3.3, ram control register (ramcr). example of real-time emulation of flash memory an example of ram area h'ff800 to h'ffbff overlapping eb2 (h'00800 to h'00bff) flash memory area is shown below. h'00000 h'00800 h'fef10 h'ffc00 h'ff800 h'fff0f h'00bff h'00fff eb2 area flash memory space on-chip ram area block area * overlapping ram (real ram area) (image ram area) procedure: part (h'ff800 to h'ffbff) of ram overlaps the area (eb2) needed to carry out real-time reprogramming. (bits 3 to 1 in the ramcr are set to 1, 1, 0 and the overlap flash memory area (eb2) is selected.) real-time reprogramming is carried out using the overlapping ram. after the reprogramming data is verified, ram overlapping is released. (rams bits are cleared.) the data written to h'ff800 to h'ffbff in ram are written to flash memory space. 1. 2. 3. 4. note: * when part (h'ff800 to h'ffbff) of ram overlapped a small block area of flash memory, the overlapped flash memory area cannot be accessed. this area can be accessed by releasing overlapping. h'ffbff figure 15.14 example of ram overlapping operation
section 15 rom rev.3.00 mar. 26, 2007 page 475 of 682 rej09b0353-0300 notes on use of the ram emulation function (1) notes on flash write enable (fwe) high/low care is necessary to prevent erroneous programming/erasing at fwe = high/low, the same as in the on-board programming mode. to prevent erroneous programming and erasing due to program runaway, etc., during fwe application, in particular, the watchdog timer should be set when the p, or e bit is set to 1 in flmcr, even while the emulation function is being used. for more information, see section 15.9, notes on flash memory programming/erasing. (2) nmi input disable conditions when the p and e bits in flmcr are set, nmi input is disabled, the same as normal program/erase even when using the emulation function. nmi input is cleared when the p and e bits are reset (including watchdog timer reset), in the standby mode, when a high level is not applied to fwe, and when the swe bit in flmcr is 0 in state in which a high level is input to fwe. 15.8 flash memory prom mode 15.8.1 prom mode setting this lsi has a prom mode, besides an on-board programming mode, as a flash memory program/erase mode. in the prom mode, a program can be freely written to the on-chip rom using a prom programmer that supports the renesas technology 128 kbytes flash memory on- chip microcomputer device type. for notes on prom mode use, see sections 15.8.9, notes on memory programming and 15.9, notes on flash memory programming/erasing.
section 15 rom rev.3.00 mar. 26, 2007 page 476 of 682 rej09b0353-0300 15.8.2 memory map figure 15.15 shows the prom mode memory map. this lsi h'00000 h'1ffff h'00000 h'1ffff address in mcu mode address in prom mode on-chip rom area figure 15.15 prom mode memory map 15.8.3 prom mode operation table 15.10 shows how the different operating modes are set when using prom mode, and table 15.11 lists the commands used in prom mode. details of each mode are given below. ? memory read mode memory read mode supports byte reads. ? auto-program mode auto-program mode supports programming of 128 bytes at a time. status polling is used to confirm the end of auto-programming. ? auto-erase mode auto-erase mode supports automatic erasing of the entire flash memory. status polling is used to confirm the end of auto-erasing. ? status read mode status polling is used for auto-programming and auto-erasing, and normal termination can be confirmed by reading the i/o 6 signal. in status read mode, error information is output if an error occurs.
section 15 rom rev.3.00 mar. 26, 2007 page 477 of 682 rej09b0353-0300 table 15.10 settings for each operating mode in prom mode pin names * 3 mode fwe ce ce ce ce oe oe oe oe we we we we d 0 to d 7 a 0 to a 17 read v cc or 0 l l h data output ain output disable v cc or 0l hhhi-z x command write v cc or 0 l h l data input ain * 2 chip disable * 1 v cc or 0hxxhi-z x legend: l: low level h: high level x: undefined hi-z: high impedance notes: for command writes when making a transition to auto-program or auto-erase mode, input vcc (v) to fwe. 1. chip disable is not a standby state; internally, it is an operation state. 2. ain indicates that there is also address input in auto-program mode. 3. the pin names are those assigned in this lsi prom mode. table 15.11 prom mode commands 1st cycle 2nd cycle command name number of cycles mode address data mode address data memory read mode 1 write x h'00 read ra dout auto-program mode 129 write x h'40 write wa din auto-erase mode 2 write x h'20 write x h'20 status read mode 2 write x h'71 write x h'71 legend: ra: read address wa: program address dout: read data din: program data note: in auto-program mode, 129 cycles are required for command writing by a simultaneous 128-byte write.
section 15 rom rev.3.00 mar. 26, 2007 page 478 of 682 rej09b0353-0300 table 15.12 dc characteristics in memory read mode conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min typ max unit test conditions input high voltage 0 7 ? 0 0 , a 16 ? a 0 v ih 2.2 ? vcc +0.3 v input low voltage 0 7 ? 0 0 , a 16 ? a 0 v il 0.3 ? 0.8 v oe , ce , we v t ? 1.0 ? 2.5 v schmitt trigger input voltage v t + 2.0 ? 3.5 v v t + ? v t ? 0.4 ?? v output high voltage 0 7 ? 0 0 v oh 2.4 ?? vi oh = ? 200 a output low voltage 0 7 ? 0 0 v ol ?? 0.45 v i ol = 1.6 ma input leakage current 0 7 ? 0 0 , a 16 ? a 0 | i li | ?? 2a v cc current reading i cc ? 40 65 ma programming i cc ? 50 85 ma erasing i cc ? 50 85 ma note: for the electrical characteristics of the flash memory version, see section 18.2.1, absolute maximum ratings. exceeding the absolute maximum ratings may cause permanent damage to the chip.
section 15 rom rev.3.00 mar. 26, 2007 page 479 of 682 rej09b0353-0300 15.8.4 memory read mode ac characteristics table 15.13 ac characteristics in memory read mode transition conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes command write cycle t nxtc 20 ? s ce hold time t ceh 0 ? ns ce setup time t ces 0 ? ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns we rise time t r ? 30 ns we fall time t f ? 30 ns ce a16 ? a0 i/o7 ? i/o0 oe we command write t ceh t ds t dh t f t r t nxtc note: data is latched on the rising edge of we . t ces t wep memory read mode address stable figure 15.16 timing waveform in memory read mode transition
section 15 rom rev.3.00 mar. 26, 2007 page 480 of 682 rej09b0353-0300 table 15.14 ac characteristics in memory contents read conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes access time t acc ? 20 s ce output delay time t ce ? 150 ns oe output delay time t oe ? 150 ns output disable delay time t df ? 100 ns data output hold time t oh 5 ? ns ce a16 ? a0 i/o7 ? i/o0 oe we v ih v il v il t acc t oh t oh t acc address stable address stable figure 15.17 ce ce ce ce / oe oe oe oe enable state read ce a16 ? a0 i/o7 ? i/o0 v ih oe we t ce t acc t oe t oh t oh t df t ce t acc t oe address stable address stable t df figure 15.18 ce ce ce ce / oe oe oe oe clock read
section 15 rom rev.3.00 mar. 26, 2007 page 481 of 682 rej09b0353-0300 table 15.15 ac characteristics in transition from memory read mode to another mode conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes command write cycle t nxtc 20 ? s ce hold time t ceh 0 ? ns ce setup time t ces 0 ? ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns we rise time t r ? 30 ns we fall time t f ? 30 ns ce a16 ? a0 i/o7 ? i/o0 oe we another mode command write t ceh t ds t dh t f t r t nxtc note: do not enable we and oe simultaneously. t ces t wep memory read mode address stable figure 15.19 transition from memory read mode to another mode
section 15 rom rev.3.00 mar. 26, 2007 page 482 of 682 rej09b0353-0300 15.8.5 auto-program mode ac characteristics table 15.16 ac characteristics in auto-program mode conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes command write cycle t nxtc 20 ? s ce hold time t ceh 0 ? ns ce setup time t ces 0 ? ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns status polling start time t wsts 1 ? ms status polling access time t spa ? 150 ns address setup time t as 0 ? ns address hold time t ah 60 ? ns memory write time t write 1 3000 ms we rise time t r ? 30 ns we fall time t f ? 30 ns write setup time t pns 100 ? ns write end setup time t pnh 100 ? ns
section 15 rom rev.3.00 mar. 26, 2007 page 483 of 682 rej09b0353-0300 address stable ce fwe a16 ? a0 i/o5 ? i/o0 i/o6 i/o7 oe we t as t ah t dh t ds t f t r t wep t wsts t write t spa t pns t pnh t nxtc t nxtc t ceh t ces programming operation end identification signal programming normal end identification signal data transfer 1byte to 128bytes h'40 h'00 figure 15.20 auto-program mode timing waveforms cautions on use of auto-program mode ? in auto-program mode, 128 bytes are programmed simultaneously. this should be carried out by executing 128 consecutive byte transfers. ? a 128-byte data transfer is necessary even when programming fewer than 128 bytes. in this case, h'ff data must be written to the extra addresses. ? if a value other than an effective address is input, processing will switch to a memory write operation but a write error will be flagged. ? memory address transfer is performed in the second cycle (figure 15.20). do not perform transfer after the second cycle. ? do not perform a command write during a programming operation. ? perform one auto-programming operation for a 128-byte block for each address. characteristics are not guaranteed for two or more programming operations. ? confirm normal end of auto-programming by checking i/o 6. alternatively, status read mode can also be used for this purpose.
section 15 rom rev.3.00 mar. 26, 2007 page 484 of 682 rej09b0353-0300 15.8.6 auto-erase mode ac characteristics table 15.17 ac characteristics in auto-erase mode conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes command write cycle t nxtc 20 ? s ce hold time t ceh 0 ? ns ce setup time t ces 0 ? ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns status polling start time t ests 1 ? ms status polling access time t spa ? 150 ns memory erase time t erase 100 40000 ms we rise time t r ? 30 ns we fall time t f ? 30 ns erase setup time t ens 100 ? ns erase end setup time t enh 100 ? ns ce fwe a16 ? a0 i/o5 ? i/o0 i/o6 i/o7 oe we t ests t erase t spa t dh t ds t f t r t wep t ens t enh t nxtc t nxtc t ceh t ces erase end identification signal erase normal and confirmation signal h'20 h'20 h'00 figure 15.21 auto-erase mode timing waveforms
section 15 rom rev.3.00 mar. 26, 2007 page 485 of 682 rej09b0353-0300 caution on use of erase-program mode ? auto-erase mode supports only entire memory erasing. ? do not perform a command write during auto-erasing. ? confirm normal end of auto-erasing by checking i/o 6. alternatively, status read mode can also be used for this purpose. 15.8.7 status read mode ac characteristics table 15.18 ac characteristics in status read mode conditions: v cc = 5.0 v 10 % , v ss = 0 v, t a = 25 c 5 c item symbol min max unit notes command write cycle t nxtc 20 ? s ce hold time t ceh 0 ? ns ce setup time t ces 0 ? ns data hold time t dh 50 ? ns data setup time t ds 50 ? ns write pulse width t wep 70 ? ns oe output delay time t oe ? 150 ns disable delay time t df ? 100 ns ce output delay time t ce ? 150 ns we rise time t r ? 30 ns we fall time t f ? 30 ns
section 15 rom rev.3.00 mar. 26, 2007 page 486 of 682 rej09b0353-0300 ce a16 ? a0 i/o7 ? i/o0 oe we t dh t df t ds t f t r t wep t nxtc t nxtc t f t r t wep t ds t dh t nxtc t ceh t ceh t oe t ces t ces t ce h'71 h'71 note: i/o3 and i/o2 are undefined. figure 15.22 status read mode timing waveforms table 15.19 status read mode return commands pin name i/o7 i/o6 i/o5 i/o4 i/o3 i/o2 i/o1 i/o0 attribute normal end identification command error program- ming error erase error ?? program- ming or erase count exceeded effective address error initial value 0 0 0 0 0 0 0 0 indications normal end: 0 abnormal end: 1 command error: 1 otherwise: 0 program- ming error: 1 otherwise: 0 erase error: 1 otherwise: 0 ?? count exceeded: 1 otherwise: 0 effective address error: 1 otherwise: 0 notes on status read mode after exiting auto-program mode or auto-erase mode, status read mode must be executed without dropping the power supply. immediately after powering on, or once powering off, the return command is undefined.
section 15 rom rev.3.00 mar. 26, 2007 page 487 of 682 rej09b0353-0300 15.8.8 prom mode transition time commands cannot be accepted during the oscillation stabilization period or the prom mode setup period. after the prom mode setup time, a transition is made to memory read mode. table 15.20 stipulated transition times to command wait state item symbol min max unit notes standby release (oscillation settling time) t osc1 20 ? ms prom mode setup time t bmv 10 ? ms v cc hold time t dwn 0 ? ms v cc res fwe memory read mode command wait state command wait state normal/abnormal end identification auto-program mode auto-erase mode t osc1 t bmv t dwn note: set the fwe input pin low level, except in the auto-program and auto-erase modes. figure 15.23 oscillation stabilization time, boot program transfer time
section 15 rom rev.3.00 mar. 26, 2007 page 488 of 682 rej09b0353-0300 15.8.9 notes on memory programming ? when programming addresses which have previously been programmed, carry out auto- erasing before auto-programming (figure 15.24). ? when performing programming using prom mode on a chip that has been programmed/erased in an on-board programming mode, auto-erasing is recommended before carrying out auto-programming. notes: 1. the flash memory is initially in the erased state when the device is shipped by renesas. for other chips for which the erasure history is unknown, it is recommended that auto- erasing be executed to check and supplement the initialization (erase) level. 2. in the prom mode, auto-programming to a 128-byte programming unit block should be performed only once. do not perform additional programming to a programmed 128-byte programming unit block. to reprogram, perform auto-programming after auto-erasing. reprogram to programmed address auto-erase (chip batch) auto-program end figure 15.24 reprogramming to programmed address 15.9 notes on flash memory programming/erasing the following describes notes when using the on-board programming mode, ram emulation function, and prom mode. (1) program/erase with the specified voltage and timing. applied voltages in excess of the rating can permanently damage the device. use a prom writer that supports the renesas technology 128 kbytes flash memory on-board microcomputer device type. do not set the prom writer at the hn28f101. if the prom writer is set to the hn28f101 by mistake, a high level can be input to the fwe pin and the lsi can be destroyed.
section 15 rom rev.3.00 mar. 26, 2007 page 489 of 682 rej09b0353-0300 (2) notes on powering on/powering off (see figures 15.25 to 15.27.) input a high level to the fwe pin after verifying vcc. before turning off vcc, set the fwe pin to a low level. when powering on and powering off the vcc power supply, fix the fwe pin a low level and set the flash memory to the hardware protection mode. be sure that the powering on and powering off timing is satisfied even when the power is turned off and back on in the event of a power interruption, etc. if this timing is not satisfied, microcomputer runaway, etc., may cause overprogramming or overerasing and the memory cells may not operate normally. (3) notes on fwe pin high/low switching (see figures 15.25 to 15.27.) input fwe in the state microcomputer operation is verified. if the microcomputer does not satisfy the operation confirmation state, fix the fwe pin at a low level to set the protection mode. to prevent erroneous programming/erasing of flash memory, note the following in fwe pin high/low switching:  apply an input to the fwe pin after the vcc voltage has stabilized within the rated voltage. if an input is applied to the fwe pin when the microcomputer vcc voltage does not satisfy the rated voltage, flash memory may be erroneously programmed or erased because the microcomputer is in the unconfirmed state.  apply an input to the fwe pin when the oscillation has stabilized (after the oscillation stabilization time). when turning on the vcc power, apply an input to the fwe pin after holding the res pin at a low level during the oscillation stabilization time (t osc1 =20ms). do not apply an input to the fwe pin when oscillation is stopped or unstable.  in the boot mode, perform fwe pin high/low switching during reset. in transition to the boot mode, input fwe = high level and set md 2 to md 0 while the res input is low. at this time, the fwe and md 2 to md 0 inputs must satisfy the mode programming setup time (t mds ) relative to the reset clear timing. the mode programming setup time is necessary for res reset timing even in transition from the boot mode to another mode. in reset during operation, the res pin must be held at a low level for at least 20 system clocks.  in the user program mode, fwe = high/low switching is possible regardless of the res input. fwe input switching is also possible during program execution on flash memory.
section 15 rom rev.3.00 mar. 26, 2007 page 490 of 682 rej09b0353-0300  apply an input to fwe when the program is not running away. when applying an input to the fwe pin, the program execution state must be supervised using a watchdog timer, etc.  input low level to the fwe pin when the swe, esu, psu, ev, pv, e, and p bits in flmcr have been cleared. do not erroneously set the swe, esu, psu, ev, pv, e, and p bits when fwe high/low. (4) do not input a constant high level to the fwe pin. to prevent erroneous programming/erasing in the event of program runaway, etc., input a high level to the fwe pin only when programming/erasing flash memory (including flash memory emulation by ram). avoid system configurations that constantly input a high level to the fwe pin. handle program runaway, etc. by starting the watchdog timer so that flash memory is not overprogrammed/overerased even while a high level is input to the fwe pin. (5) program/erase the flash memory in accordance with the recommended algorithms. the recommended algorithms can program/erase the flash memory without applying voltage stress to the device or sacrificing the reliability of the program data. when setting the psu and esu bits in flmcr, set the watchdog timer for program runaway, etc. (6) do not set/clear the swe bit while a program is executing on flash memory. before performing flash memory program execution or data read, clear the swe bit. if the swe bit is set, the flash data can be reprogrammed, but flash memory cannot be accessed for purposes other than verify (verify during programming/erase). similarly perform flash memory program execution and data read after clearing the swe bit even when using the ram emulation function with a high level input to the fwe pin. however, ram area that overlaps flash memory space can be read/programmed whether the swe bit is set or cleared. (7) do not use an interrupt during flash memory programming or erasing. since programming/erase operations (including emulation by ram) have priority when a high level is input to the fwe pin, disable all interrupt requests, including nmi. (8) do not perform additional programming. reprogram flash memory after erasing. with on-board programming, program to 32-byte programming unit blocks one time only. program to 128-byte programming unit blocks one time only even in the prom mode. erase all the programming unit blocks before reprogramming. bus release must also be disabled.
section 15 rom rev.3.00 mar. 26, 2007 page 491 of 682 rej09b0353-0300 (9) before programming, check that the chip is correctly mounted in the prom programmer. overcurrent damage to the device can result if the index marks on the prom programmer socket, socket adapter, and chip are not correctly aligned. (10) do not touch the socket adapter or chip during programming. touching either of these can cause contact faults and write errors. : flash memory access disabled period (x: wait time after swe setting) * 2 : flash memory reprogrammable period (flash memory program execution and data read, other than verify, are disabled.) 1. always fix the level by pulling down or pulling up the mode pins (md 2 to md 0 ) until powering off, except for mode switching. 2. see section 18.2.5, flash memory characteristics. notes: v cc fwe t osc1 min 0 s min 0 s t mds t mds md 2 to md 0 * 1 res swe bit swe set swe clear programming and erase possible wait time: x figure 15.25 powering on/off timing (boot mode)
section 15 rom rev.3.00 mar. 26, 2007 page 492 of 682 rej09b0353-0300 : flash memory access disabled period (x: wait time after swe setting) * 2 : flash memory reprogrammable period (flash memory program execution and data read, other than verify, are disabled.) 1. always fix the level by pulling down or pulling up the mode pins (md 2 to md 0 ) except for mode switching. 2. see section 18.2.5, flash memory characteristics. notes: v cc fwe t osc1 min 0 s t mds md 2 to md 0 * 1 res swe bit swe set swe clear programming and erase possible wait time: x figure 15.26 powering on/off timing (user program mode)
section 15 rom rev.3.00 mar. 26, 2007 page 493 of 682 rej09b0353-0300 : flash memory access disabled time (x: wait time after swe setting) * 3 : flash memory reprogammable period (flash memory program execution and data read, other than verify, are disabled.) 1. in transition to the boot mode and transition from the boot mode to another mode, mode switching via res input is necessary. during this switching period (period during which a low level is input to the res pin), the state of the address dual port and bus control output signals ( as , rd , wr ) changes. therefore, do not use these pins as output signals during this switching period. 2. when making a transition from the boot mode to another mode, the mode programming setup time t mds relative to the res clear timing is necessary. 3. see section 18.2.5, flash memory characteristics. notes: v cc fwe t osc1 min 0 s t mds * 2 t mds t mds t resw md 2 to md 0 res swe bit mode switching * 1 mode switching * 1 boot mode user mode user mode user program mode user program mode swe set swe clear programming and erase possible wait time: x programming and erase possible programming and erase possible wait time: x programming and erase possible wait time: x wait time: x figure 15.27 mode transition timing (example: boot mode user mode ? ? ? ? user program mode)
section 15 rom rev.3.00 mar. 26, 2007 page 494 of 682 rej09b0353-0300 15.10 mask rom overview 15.10.1 block diagram figure 15.28 shows a block diagram of the rom. h'00000 h'00002 h'1fffe h'00001 h'00003 h'1ffff internal data bus (upper 8 bits) internal data bus (lower 8 bits) on-chip rom even addresses odd addresses figure 15.28 rom block diagram (h8/3039)
section 15 rom rev.3.00 mar. 26, 2007 page 495 of 682 rej09b0353-0300 15.11 notes on ordering mask rom version chip when ordering the h8/3039 group chips with a mask rom, note the following. ? when ordering through an eprom, use a 128-kbyte one. ? fill all the unused addresses with h'ff as shown in figure15.29 to make the rom data size 128 kbytes for all h8/3039 group chips, which incorporate different sizes of rom. this applies to ordering through an eprom and through electrical data transfer. ? the flash memory versions only registers for flash memory control (flmcr, ebr, ramcr, and flmsr) are not provided in the mask rom versions. reading the corresponding addresses in a mask rom version will always return 1s, and writes to these addresses are disabled. this must be borne in mind when switching from the flash memory versions to a mask rom version. hd6433039 (rom: 128 kbytes) address: h'00000 ? h'1ffff h'00000 h'1ffff note: * program h'ff to all addresses in these areas. hd6433038 (rom: 64 kbytes) address: h'00000 ? h'0ffff h'00000 h'1ffff not used * not used * hd6433037 (rom: 32 kbytes) address: h'00000 ? h'07fff h'00000 h'07fff h'08000 h'0ffff h'10000 h'1ffff not used * hd6433036 (rom: 16 kbytes) address: h'00000 ? h'03fff h'00000 h'03fff h'04000 h'1ffff figure 15.29 mask rom addresses and data
section 15 rom rev.3.00 mar. 26, 2007 page 496 of 682 rej09b0353-0300
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 497 of 682 rej09b0353-0300 section 16 clock pulse generator 16.1 overview this lsi has a built-in clock pulse generator (cpg) that generates the system clock ( ) and other internal clock signals ( /2 to /4096). after duty adjustment, a frequency divider divides the clock frequency to generate the system clock ( ). the system clock is output at the pin* 1 and furnished as a master clock to prescalers that supply clock signals to the on-chip supporting modules. frequency division ratios of 1/1, 1/2, 1/4, and 1/8 can be selected for the frequency divider by settings in a division control register (divcr). power consumption in the chip is reduced in almost direct proportion to the frequency division ratio* 2 . notes: 1. usage of the pin differs depending on the chip operating mode and the pstop bit setting in the module standby control register (mstcr). for details, see section 17.7, system clock output disabling function. 2. the division ratio of the frequency divider can be changed dynamically during operation. the clock output at the pin also changes when the division ratio is changed. the frequency output at the pin is shown below. = extal n extal: frequency of crystal resonator or external clock signal n: frequency division ratio (n = 1/1, 1/2, 1/4, or 1/8)
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 498 of 682 rej09b0353-0300 16.1.1 block diagram figure 16.1 shows a block diagram of the clock pulse generator. xtal extal cpg ? /2 to /4096 oscillator duty adjustment circuit prescalers frequency divider division control register data bus figure 16.1 block diagram of clock pulse generator 16.2 oscillator circuit clock pulses can be supplied by connecting a crystal resonator, or by input of an external clock signal.
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 499 of 682 rej09b0353-0300 16.2.1 connecting a crystal resonator circuit configuration a crystal resonator can be connected as in the example in figure 16.2. the damping resistance rd should be selected according to table 16.1. an at-cut parallel-resonance crystal should be used. extal xtal c l1 c l2 c = c = 10 pf to 22 pf l1 l2 rd figure 16.2 connection of crystal resonator (example) table 16.1 damping resistance value (example) frequency (mhz) 2 4 8 10121618 rd ( ? ? ? ? ) 1 k 500 200 0 0 0 0 crystal resonator figure 16.3 shows an equivalent circuit of the crystal resonator. the crystal resonator should have the characteristics listed in table 16.2. xtal lrs c l c o extal at-cut parallel-resonance type figure 16.3 crystal resonator equivalent circuit
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 500 of 682 rej09b0353-0300 table 16.2 crystal resonator parameters frequency (mhz) 24810121618 rs max ( ? ? ? ? ) 500 120 80 70 60 50 40 co max (pf) 7777777 use a crystal resonator with a frequency equal to the system clock frequency ( ). notes on board design when a crystal resonator is connected, the following points should be noted: other signal lines should be routed away from the oscillator circuit to prevent induction from interfering with correct oscillation. see figure 16.4. when the board is designed, the crystal resonator and its load capacitors should be placed as close as possible to the xtal and extal pins. xtal extal c l2 c l1 lsi avoid signal a signal b figure 16.4 example of incorrect board design
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 501 of 682 rej09b0353-0300 16.2.2 external clock input circuit configuration an external clock signal can be input as shown in the examples in figure 16.5. in example b, the clock should be held high in standby mode. if the xtal pin is left open, the stray capacitance should not exceed 10 pf. extal xtal extal xtal 74hc04 external clock input open external clock input a. xtal pin left open b. complementary clock input at xtal pin figure 16.5 external clock input (examples)
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 502 of 682 rej09b0353-0300 external clock the external clock frequency should be equal to the system clock frequency ( ). table 16.3 and figure 16.6 indicate the clock timing. table 16.3 clock timing v cc = 2.7 v to 5.5 v v cc = 5.0 v 10% item symbol min max min max unit test conditions external clock rise time t exr ? 10 ? 5 ns figure 16.6 external clock fall time t exf ?10 ?5 ns external clock ? 30 70 30 70 % 5 mhz input duty (a/t cyc )40604060% < 5 mhz clock width duty (b/t cyc ) ?40604060% figure 16.6 t cyc a extal t exr t exf v cc figure 16.6 external clock input timing
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 503 of 682 rej09b0353-0300 table 16.4 and figure 16.7 show the timing for the external clock output stabilization delay time. the oscillator and duty correction circuit have the function of regulating the waveform of the external clock input to the extal pin. when the specified clock signal is input to the extal pin, internal clock signal output is confirmed after the elapse of the external clock output stabilization delay time (t dext ). as clock signal output is not confirmed during the t dext period, the reset signal should be driven low and the reset state maintained during this time. table 16.4 external clock output stabilization delay time conditions: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v item symbol min max unit notes external clock output stabilization delay time t dext * 500 ? s figure 16.7 note: * t dext includes a 10 t cyc res pulse width (t resw ). v cc stby extal res t dext * note: * t dext includes a 10 t cyc res pulse width (t resw ). 2.7 v v ih figure 16.7 external clock output stabilization delay time
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 504 of 682 rej09b0353-0300 16.3 duty adjustment circuit when the oscillator frequency is 5 mhz or higher, the duty adjustment circuit adjusts the duty cycle of the clock signal from the oscillator to generate the system clock ( ). 16.4 prescalers the prescalers divide the system clock ( ) to generate internal clocks ( /2 to /4096). 16.5 frequency divider the frequency divider divides the duty-adjusted clock signal to generate the system clock ( ). the frequency division ratio can be changed dynamically by modifying the value in divcr, as described below. power consumption in the chip is reduced in almost direct proportion to the frequency division ratio. the system clock generated by the frequency divider can be output at the pin. 16.5.1 register configuration table 16.5 summarizes the frequency division register. table 16.5 frequency division register address * name abbreviation r/w initial value h'ff5d division control register divcr r/w h'fc note: * the lower 16 bits of the address are shown.
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 505 of 682 rej09b0353-0300 16.5.2 division control register (divcr) divcr is an 8-bit readable/writable register that selects the division ratio of the frequency divider. bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 div0 0 r/w 2 ? 1 ? 1 div1 0 r/w reserved bits divide bits 1 and 0 these bits select the frequency division ratio divcr is initialized to h'fc by a reset and in hardware standby mode. it is not initialized in software standby mode. bits 7 to 2?reserved: these bits cannot be modified and are always read as 1. bits 1 and 0?divide (div1 and div0): these bits select the frequency division ratio, as follows. bit 1 div1 bit 0 div0 frequency division ratio 0 0 1/1 (initial value) 01 1/2 10 1/4 11 1/8
section 16 clock pulse generator rev.3.00 mar. 26, 2007 page 506 of 682 rej09b0353-0300 16.5.3 usage notes the divcr setting changes the frequency, so note the following points. ? select a frequency division ratio that stays within the assured operation range specified for the clock cycle time t cyc in the ac electrical characteristics. note that min = 1 mhz. avoid settings that give system clock frequencies less than 1 mhz. all on-chip module operations are based on . note that the timing of timer operations, serial communication, and other time-dependent processing differs before and after any change in the division ratio. the waiting time for exit from software standby mode also changes when the division ratio is changed. for details, see section 17.4.3, selection of oscillator waiting time after exit from software standby mode
section 17 power-down state rev.3.00 mar. 26, 2007 page 507 of 682 rej09b0353-0300 section 17 power-down state 17.1 overview this lsi has a power-down state that greatly reduces power consumption by halting cpu functions, and a module standby function that reduces power consumption by selectively halting on-chip modules. the power-down state includes the following three modes: ? sleep mode ? software standby mode ? hardware standby mode the module standby function can halt on-chip supporting modules independently of the power- down state. the modules that can be halted are the itu, sci0, sci1, and a/d converter. table 17.1 indicates the methods of entering and exiting these power-down modes and the status of the cpu and on-chip supporting modules in each mode.
section 17 power-down state rev.3.00 mar. 26, 2007 page 508 of 682 rej09b0353-0300 table 17.1 power-down state and module standby function state entering conditions cpu registers supporting modules exiting methods mode clock cpu itu sci0 sci1 a/d ram sleep sleep instruc- active halted held active active active active active held  interrupt mode tion executed  res while ssby = 0  stby in syscr software sleep instruc- halted halted held halted halted halted halted halted held  nmi standby tion executed and and and and and  irq 0 to irq 1 mode while ssby = 1 reset reset reset reset reset  res in syscr  stby hardware low input at halted halted undeter halted halted halted halted halted held * 2  stby standby stby pin mined and and and and and  res mode reset reset reset reset reset module corresponding active active ? halted * 1 halted * 1 halted * 1 halted * 1 active  stby standby function bit set to 1 in and and and and  res mstcr reset reset reset reset  clear mstcr bit to 0 * 3 clock output output high output high impedance high impedance * 1 ? i/o ports held held high impedance notes: 1. state in which the corresponding mstcr bit was set to 1. for details see section 17.2.2, module standby control reg ister (mstcr). 2. the rame bit must be cleared to 0 in syscr before the transition from the program execution state to hardware standby mode. 3. when a mstcr bit is set to 1, the registers of the corresponding on-chip supporting module are initialized. to restart the module, first clear the mstcr bit to 0, then set up the module registers again. legend: syscr: system control register ssby: software standby bit mstcr: module standby control register ?
section 17 power-down state rev.3.00 mar. 26, 2007 page 509 of 682 rej09b0353-0300 17.2 register configuration this lsi has a system control register (syscr) that controls the power-down state, and a module standby control register (mstcr) that controls the module standby function. table 17.2 summarizes this register. table 17.2 register configuration address * name abbreviation r/w initial value h'fff2 system control register syscr r/w h'0b h'ff5e module standby control register mstcr r/w h'40 note: * lower 16 bits of the address. 17.2.1 system control register (syscr) bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ue 1 r/w 0 rame 1 r/w 2 nmieg 0 r/w 1 ? 1 ? software standby enables transition to software standby mode ram enable standby timer select 2 to 0 these bits select the waiting time at exit from software standby mode user bit enable nmi edge select reserved bit syscr is an 8-bit readable/writable register. bit 7 (ssby) and bits 6 to 4 (sts2 to sts0) control the power-down state. for information on the other syscr bits, see section 3.3, system control register (syscr).
section 17 power-down state rev.3.00 mar. 26, 2007 page 510 of 682 rej09b0353-0300 bit 7?software standby (ssby): enables transition to software standby mode. when software standby mode is exited by an external interrupt, this bit remains set to 1 after the return to normal operation. to clear this bit, write 0. bit 7 ssby description 0 sleep instruction causes transition to sleep mode (initial value) 1 sleep instruction causes transition to software standby mode bits 6 to 4?standby timer select (sts2 to sts0): these bits select the length of time the cpu and on-chip supporting modules wait for the clock to settle when software standby mode is exited by an external interrupt. if the clock is generated by a crystal resonator, set these bits according to the clock frequency so that the waiting time (for the clock to stabilize) will be at least 7 ms. see table 17.3. if an external clock is used, any setting is permitted. bit 6 sts2 bit 5 sts1 bit 4 sts0 description 0 0 0 waiting time = 8192 states (initial value) 1 waiting time = 16384 states 1 0 waiting time = 32768 states 1 waiting time = 65536 states 1 0 0 waiting time = 131072 states 0 1 waiting time = 1024 states 1 ? illegal setting
section 17 power-down state rev.3.00 mar. 26, 2007 page 511 of 682 rej09b0353-0300 17.2.2 module standby control register (mstcr) mstcr is an 8-bit readable/writable register that controls output of the system clock ( ). it also controls the module standby function, which places individual on-chip supporting modules in the standby state. module standby can be designated for the itu, sci0, sci1, and a/d converter modules. bit initial value read/write 7 pstop 0 r/w 6 ? 1 ? 5 mstop5 0 r/w 4 mstop4 0 r/w 3 mstop3 0 r/w 0 mstop0 0 r/w 2 ? 0 ? 1 ? 0 ? clock stop enables or disables output of the system clock module standby 5 to 3, and 0 these bits select modules to be placed in standby reserved bit reserved bit mstcr is initialized to h'40 by a reset and in hardware standby mode. it is not initialized in software standby mode. bit 7? clock stop (pstop): enables or disables output of the system clock ( ). bit 7 pstop description 0 system clock output is enabled (initial value) 1 system clock output is disabled bit 6?reserved: this bit cannot be modified and is always read as 1. bit 5?module standby 5 (mstop5): selects whether to place the itu in standby. bit 5 mstop5 description 0 itu operates normally (initial value) 1 itu is in standby state
section 17 power-down state rev.3.00 mar. 26, 2007 page 512 of 682 rej09b0353-0300 bit 4?module standby 4 (mstop4): selects whether to place sci0 in standby. bit 4 mstop4 description 0 sci0 operates normally (initial value) 1 sci0 is in standby state bit 3?module standby 3 (mstop3): selects whether to place sci1 in standby. bit 3 mstop3 description 0 sci1 operates normally (initial value) 1 sci1 is in standby state bits 2 to 1?reserved: bits 2 to 1 are reserved. bit 0?module standby 0 (mstop0): selects whether to place the a/d converter in standby. bit 0 mstop0 description 0 a/d converter operates normally (initial value) 1 a/d converter is in standby state
section 17 power-down state rev.3.00 mar. 26, 2007 page 513 of 682 rej09b0353-0300 17.3 sleep mode 17.3.1 transition to sleep mode when the ssby bit is cleared to 0 in the system control register (syscr), execution of the sleep instruction causes a transition from the program execution state to sleep mode. immediately after executing the sleep instruction the cpu halts, but the contents of its internal registers are retained. the on-chip supporting modules do not halt in sleep mode. on-chip supporting modules which have been placed in standby by the module standby function, however, remain halted. 17.3.2 exit from sleep mode sleep mode is exited by an interrupt, or by input at the res or stby pin. exit by interrupt: an interrupt terminates sleep mode and causes a transition to the interrupt exception handling state. sleep mode is not exited by an interrupt source in an on-chip supporting module if the interrupt is disabled in the on-chip supporting module. sleep mode is not exited by an interrupt other then nmi if the interrupt is masked by interrupt priority settings (ipr) and the settings of the i and ui bits in ccr. exit by res res res res input: low input at the res pin exits from sleep mode to the reset state. exit by stby stby stby stby input: low input at the stby pin exits from sleep mode to hardware standby mode.
section 17 power-down state rev.3.00 mar. 26, 2007 page 514 of 682 rej09b0353-0300 17.4 software standby mode 17.4.1 transition to software standby mode to enter software standby mode, execute the sleep instruction while the ssby bit is set to 1 in syscr. in software standby mode, current dissipation is reduced to an extremely low level because the cpu, clock, and on-chip supporting modules all halt. the on-chip supporting modules are reset and halted. as long as the specified voltage is supplied, however, cpu register contents and on- chip ram data are retained. the settings of the i/o ports are also held. 17.4.2 exit from software standby mode software standby mode can be exited by input of an external interrupt at the nmi, irq 0 , irq 1 , or by input at the res or stby pin. exit by interrupt: when an nmi, irq 0 , or irq 1 interrupt request signal is received, the clock oscillator begins operating. after the oscillator settling time selected by bits sts2 to sts0 in syscr, stable clock signals are supplied to the entire chip, software standby mode ends, and interrupt exception handling begins. software standby mode is not exited if the interrupt enable bits of interrupts irq 0 , and irq 1 are cleared to 0, or if these interrupts are masked in the cpu. exit by res res res res input: when the res input goes low, the clock oscillator starts and clock pulses are supplied immediately to the entire chip. the res signal must be held low long enough for the clock oscillator to stabilize. when res goes high, the cpu starts reset exception handling. exit by stby stby stby stby input: low input at the stby pin causes a transition to hardware standby mode.
section 17 power-down state rev.3.00 mar. 26, 2007 page 515 of 682 rej09b0353-0300 17.4.3 selection of oscillator waiting time after exit from software standby mode bits sts2 to sts0 in syscr, and its div1 and div0 in divcr should be set as follows. crystal resonator set sts2 to sts0, and div1 and div0 so that the waiting time (for the clock to stabilize) is at least 7 ms. table 17.3 indicates the waiting times that are selected by sts2 to sts0, and div1 and div0 settings at various system clock frequencies. external clock any value may be set. table 17.3 clock frequency and waiting time for clock to settle div1 div0 sts2 sts1 sts0 waiting time 18 mhz 16 mhz 12 mhz 10 mhz 8 mhz 6 mhz 4 mhz 2 mhz 1 mhz unit 0 0 0 0 0 8192 states 0.46 0.51 0.65 0.8 1.0 1.3 2.0 4.1 8.2 ms 0 0 1 16384 states 0.91 1.0 1.3 1.6 2.0 2.7 4.1 8.2 16.4 0 1 0 32768 states 1.8 2.0 2.7 3.3 4.1 5.5 8.2 16.4 32.8 0 1 1 65536 states 3.6 4.1 5.5 6.6 8.2 10.9 16.4 32.8 65.5 1 0 0 131072 states 7.3 8.2 10.9 13.1 16.4 21.8 32.8 65.5 131.1 1 0 1 1024 states 0.057 0.064 0.085 0.10 0.13 0.17 0.26 0.51 1.0 11 ? 0 1 0 0 0 8192 states 0.91 1.02 1.4 1.6 2.0 2.7 4.1 8.2 16.4 ms 0 0 1 16384 states 1.8 2.0 2.7 3.3 4.1 5.5 8.2 16.4 32.8 0 1 0 32768 states 3.6 4.1 5.5 6.6 8.2 10.9 16.4 32.8 65.5 0 1 1 65536 states 7.3 8.2 10.9 13.1 16.4 21.8 32.8 65.5 131.1 1 0 0 131072 states 14.6 16.4 21.8 26.2 32.8 43.7 65.5 131.1 262.1 1 0 1 1024 states 0.11 0.13 0.17 0.20 0.26 0.34 0.51 1.0 2.0 11 ? illegal setting illegal setting illegal setting illegal setting 1 0 0 0 0 8192 states 1.8 2.0 2.7 3.3 4.1 5.5 8.2 16.4 32.8 ms 0 0 1 16384 states 3.6 4.1 5.5 6.6 8.2 10.9 16.4 32.8 65.5 0 1 0 32768 states 7.3 8.2 10.9 13.1 16.4 21.8 32.8 65.5 131.1 0 1 1 65536 states 14.6 16.4 21.8 26.2 32.8 43.7 65.5 131.1 262.1 1 0 0 131072 states 29.1 32.8 43.7 52.4 65.5 87.4 131.1 262.1 524.3 1 0 1 1024 states 0.23 0.26 0.34 0.41 0.51 0.68 1.02 2.0 4.1 11 ? 1 1 0 0 0 8192 states 3.6 4.1 5.5 6.6 8.2 10.9 16.4 32.8 65.5 ms 0 0 1 16384 states 7.3 8.2 10.9 13.1 16.4 21.8 32.8 65.5 131.1 0 1 0 32768 states 14.6 16.4 21.8 26.2 32.8 43.7 65.5 131.1 262.1 0 1 1 65536 states 29.1 32.8 43.7 52.4 65.5 87.4 131.1 262.1 524.3 1 0 0 131072 states 58.3 65.5 87.4 104.9 131.1 174.8 262.1 524.3 1048.6 1 0 1 1024 states 0.46 0.51 0.68 0.82 1.0 1.4 2.0 4.1 8.2 11 ? : recommended setting
section 17 power-down state rev.3.00 mar. 26, 2007 page 516 of 682 rej09b0353-0300 17.4.4 sample application of software standby mode figure 17.1 shows an example in which software standby mode is entered at the fall of nmi and exited at the rise of nmi. with the nmi edge select bit (nmieg) cleared to 0 in syscr (selecting the falling edge), an nmi interrupt occurs. next the nmieg bit is set to 1 (selecting the rising edge) and the ssby bit is set to 1; then the sleep instruction is executed to enter software standby mode. software standby mode is exited at the next rising edge of the nmi signal. figure 17.1 nmi timing for software standby mode (example) 17.4.5 usage note the i/o ports retain their existing states in software standby mode. if a port is in the high output state, its output current is not reduced.
section 17 power-down state rev.3.00 mar. 26, 2007 page 517 of 682 rej09b0353-0300 17.5 hardware standby mode 17.5.1 transition to hardware standby mode regardless of its current state, the chip enters hardware standby mode whenever the stby pin goes low. hardware standby mode reduces power consumption drastically by halting all functions of the cpu and on-chip supporting modules. all modules are reset except the on-chip ram. as long as the specified voltage is supplied, on-chip ram data is retained. i/o ports are placed in the high-impedance state. clear the rame bit to 0 in syscr before stby goes low to retain on-chip ram data. the inputs at the mode pins (md 2 to md 0 ) should not be changed during hardware standby mode. 17.5.2 exit from hardware standby mode hardware standby mode is exited by inputs at the stby and res pins. while res is low, when stby goes high, the clock oscillator starts running. res should be held low long enough for the clock oscillator to settle. when res goes high, reset exception handling begins, followed by a transition to the program execution state.
section 17 power-down state rev.3.00 mar. 26, 2007 page 518 of 682 rej09b0353-0300 17.5.3 timing for hardware standby mode figure 17.2 shows the timing relationships for hardware standby mode. to enter hardware standby mode, first drive res low, then drive stby low. to exit hardware standby mode, first drive stby high, wait for the clock to settle, then bring res from low to high. res stby clock oscillator oscillator settling time reset exception handling figure 17.2 hardware standby mode timing
section 17 power-down state rev.3.00 mar. 26, 2007 page 519 of 682 rej09b0353-0300 17.6 module standby function 17.6.1 module standby timing the module standby function can halt several of the on-chip supporting modules (the itu, sci0, sci1, and a/d converter) independently of the power-down state. this standby function is controlled by bits mstop5 to mstop3 and mstop0 in mstcr. when one of these bits is set to 1, the corresponding on-chip supporting module is placed in standby and halts at the beginning of the next bus cycle after the mstcr write cycle. 17.6.2 read/write in module standby when an on-chip supporting module is in module standby, read/write access to its registers is disabled. read access always results in h'ff data. write access is ignored. 17.6.3 usage notes when using the module standby function, note the following points. cancellation of interrupt handling: when an on-chip supporting module is placed in standby by the module standby function, its registers are initialized, including registers with interrupt request flags. consequently, if an interrupt occurs just before the mstop bit is set to 1, the interrupt will not be recognized. the interrupt source will not be held pending. pin states: pins used by an on-chip supporting module lose their module functions when the module is placed in module standby. what happens after that depends on the particular pin. for details, see section 7, i/o ports. pins that change from the input to the output state require special care. for example, if sci1 is placed in module standby, the receive data pin loses its receive data function and becomes a generic i/o pin. if its data direction bit is set to 1, the pin becomes a data output pin, and its output may collide with external serial data. data collisions should be prevented by clearing the data direction bit to 0 or taking other appropriate action. register resetting: when an on-chip supporting module is halted by the module standby function, all its registers are initialized. to restart the module, after its mstop bit is cleared to 0, its registers must be set up again. it is not possible to write to the registers while the mstop bit is set to 1.
section 17 power-down state rev.3.00 mar. 26, 2007 page 520 of 682 rej09b0353-0300 17.7 system clock output disabling function output of the system clock ( ) can be controlled by the pstop bit in mstcr. when the pstop bit is set to 1, output of the system clock halts and the pin is placed in the high-impedance state. figure 17.3 shows the timing of the stopping and starting of system clock output. when the pstop bit is cleared to 0, output of the system clock is enabled. table 17.4 indicates the state of the pin in various operating states. t1 t2 (pstop = 1) t3 t1 t2 (pstop = 0) mstcr write cycle mstcr write cycle high impedance figure 17.3 starting and stopping of system clock output table 17.4 pin state in various operating states operating state pstop = 0 pstop = 1 hardware standby high impedance high impedance software standby always high high impedance sleep mode system clock output high impedance normal operation system clock output high impedance
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 521 of 682 rej09b0353-0300 section 18 electrical characteristics 18.1 electrical characteristics of mask rom version 18.1.1 absolute maximum ratings table 18.1 lists the absolute maximum ratings. table 18.1 absolute maximum ratings item symbol value unit power supply voltage v cc ?0.3 to +7.0 v input voltage (except port 7) * v in ?0.3 to v cc +0.3 v input voltage (port 7) v in ?0.3 to av cc +0.3 v analog power supply voltage av cc ?0.3 to +7.0 v analog input voltage v an ?0.3 to av cc +0.3 v operating temperature t opr regular specifications: ?20 to +75 c wide-range specifications: ?40 to +85 c storage temperature t stg ?55 to +125 c caution: permanent damage to the chip may result if absolute maximum ratings are exceeded. note: * 12 v must not be applied to any pin, as this will cause permanent damage to the chip.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 522 of 682 rej09b0353-0300 18.1.2 dc characteristics table 18.2 lists the dc characteristics. table 18.3 lists the permissible output currents. table 18.2 dc characteristics (1) conditions: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v* 1 , t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min typ max unit test conditions port a, v t ? 1.0 ? ? v p8 0 to p8 1 ,v t + ??v cc 0.7 v schmitt trigger input voltages pb 0 to pb 3 v t + ? v t ? 0.4 ? ? v input high voltage res , stby , nmi, md 2 , md 1 , md 0 v ih v cc ?0.7 ? v cc +0.3 v extal v cc 0.7 ? v cc +0.3 v port 7 2.0 ? av cc +0.3 v ports 1, 2, 3, 5, 6, 9, pb 4 , pb 5 , pb 7 2.0 ? v cc +0.3 v input low voltage res , stby , md 2 , md 1 , md 0 v il ?0.3 ? 0.5 v nmi, extal, ports 1, 2, 3, 5, 6, 7, 9, pb 4 , pb 5 , pb 7 ?0.3 ? 0.8 v v oh v cc ?0.5 ? ? v i oh = ?200 a output high voltage all output pins (except reso ) 3.5 ? ? v i oh = ?1 ma output low voltage all output pins (except reso ) v ol ??0.4vi ol = 1.6 ma ports 1, 2, 5, b ? ? 1.0 v i ol = 10 ma reso ??0.4vi ol = 2.6 ma
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 523 of 682 rej09b0353-0300 item symbol min typ max unit test conditions input leakage current stby , nmi, res , md 2 , md 1 , md 0 |i in |??1.0av in = 0.5 to v cc ?0.5 v port 7 ? ? 1.0 a v in = 0.5 to av cc ?0.5 v ports 1, 2, 3, 5, 6, 8 to b |i tsi |? ?1.0 av in = 0.5 to v cc ?0.5 v three-state leakage current (off state) reso ? ? 10.0 a input pull-up mos current ports 2, 5 ?i p 50 ? 300 a v in = 0 v nmi, res c in ? ? 50 pf input capacitance all input pins except nmi and res ??20 v in = 0 v, f = 1 mhz, t a = 25c normal operation i cc ? 50 70 ma f = 18 mhz sleep mode ? 35 50 f = 18 mhz standby mode * 3 ? 0.01 5.0 a t a 50c current dissipation * 2 ? ? 20.0 50c < t a during a/d conversion ai cc ?1.72.8ma analog power supply current idle ? 0.02 10.0 a ram standby voltage v ram 2.0 ? ? v notes: 1. if the a/d converter is not used, do not leave the av cc and av ss pins open. connect av cc to v cc , and connect av ss to v ss . 2. current dissipation values are for v ih min = v cc ?0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up transistors in the off state. 3. the values are for v ram v cc < 4.5 v, v ih min = v cc 0.9, and v il max = 0.3 v.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 524 of 682 rej09b0353-0300 table 18.2 dc characteristics (2) conditions: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v* 1 , t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min typ max unit test conditions v t ? v cc 0.2 ? ? v v t + ??v cc 0.7 v schmitt trigger input voltages port a, p8 0 to p8 1 , pb 0 to pb 3 v t + ? v t ? v cc 0.04 ? ? v input high voltage res , stby , nmi, md 2 , md 1 , md 0 v ih v cc 0.9 ? v cc +0.3 v extal v cc 0.7 ? v cc +0.3 v port 7 v cc 0.7 ? av cc +0.3 v ports 1, 2, 3, 5, 6, 9, pb 4 , pb 5 , pb 7 v cc 0.7 ? v cc +0.3 v input low voltage res , stby , md 2 , md 1 , md 0 v il ?0.3 ? v cc 0.1 v ?0.3 ? v cc 0.2 v v cc < 4.0 v nmi, extal, ports 1, 2, 3, 5, 6, 7, 9, pb 4 , pb 5 , pb 7 0.8 v v cc = 4.0 v to 5.5 v v oh v cc ?0.5 ? ? v i oh = ?200 a output high voltage all output pins (except reso ) v cc ?1.0 ? ? v i oh = ?1 ma output low voltage all output pins (except reso ) v ol ??0.4vi ol = 1.0 ma ports 1, 2, 5, b ? ? 1.0 v v cc 4 v, i ol = 5 ma, 4 v < v cc 5.5 v, i ol = 10 ma reso ??0.4vi ol = 1.6 ma input leakage current stby , nmi, res , md 2 , md 1 , md 0 |i in |? ?1.0av in = 0.5 v to v cc ?0.5 v port 7 ? ? 1.0 a v in = 0.5 v to av cc ?0.5 v
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 525 of 682 rej09b0353-0300 item symbol min typ max unit test conditions ports 1, 2, 3, 5, 6, 8, 9, a, b |i tsi |? ?1.0 a three-state leakage current (off state) reso ? ? 10.0 a v in = 0.5 v to v cc ?0.5 v input pull-up mos current ports 2, 5 ?i p 10 ? 300 a v cc = 2.7 v to 5.5 v, v in = 0 v nmi, res c in ? ? 50 pf input capacitance all input pins except nmi and res ??20 v in = 0 v, f = 1 mhz , ta = 25c current dissipation * 2 normal operation i cc * 4 ?12 (3.0 v) 33.8 (5.5 v) ma f = 8 mhz sleep mode ? 8 (3.0 v) 25.0 (5.5 v) ma f = 8 mhz standby mode * 3 ? 0.01 5.0 a t a 50c ? ? 20.0 a 50c < t a ai cc ?1.32.5maav cc = 3.0 v during a/d conversion ?1.72.8maav cc = 5.0 v analog power supply current idle ? 0.02 10.0 a ram standby voltage v ram 2.0 ? ? v notes: 1. if the a/d converter is not used, do not leave the av cc and av ss pins open. connect av cc to v cc , and connect av ss to v ss . 2. current dissipation values are for v ih min = v cc ?0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up mos transistors in the off state. 3. the values are for v ram v cc < 2.7 v, v ih min = v cc 0.9, and v il max = 0.3 v. 4. i cc depends on v cc and f as follows: i cc max = 3.0 (ma) + 0.7 (ma/mhz v) v cc f [normal mode] i cc max = 3.0 (ma) + 0.5 (ma/mhz v) v cc f [sleep mode]
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 526 of 682 rej09b0353-0300 table 18.2 dc characteristics (3) conditions: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v* 1 , t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min typ max unit test conditions v t ? v cc 0.2 ? ? v v t + ??v cc 0.7 v schmitt trigger input voltages port a, p8 0 to p8 1 , pb 0 to pb 3 v t + ? v t ? v cc 0.04 ? ? v input high voltage res , stby , nmi, md 2 , md 1 , md 0 v ih v cc 0.9 ? v cc +0.3 v extal v cc 0.7 ? v cc +0.3 v port 7 v cc 0.7 ? av cc +0.3 v ports 1, 2, 3, 5, 6, 9, pb 4 , pb 5 , pb 7 v cc 0.7 ? v cc +0.3 v input low voltage res , stby , md 2 , md 1 , md 0 v il ?0.3 ? v cc 0.1 v ?0.3 ? v cc 0.2 v v cc < 4.0 v nmi, extal, ports 1, 2, 3, 5, 6, 7, 9, pb 4 , pb 5 , pb 7 0.8 v v cc = 4.0 v to 5.5 v v oh v cc ?0.5 ? ? v i oh = ?200 a output high voltage all output pins (except reso ) v cc ?1.0 ? ? v i oh = ?1 ma output low voltage all output pins (except reso ) v ol ??0.4vi ol = 1.0 ma ports 1, 2, 5, b ? ? 1.0 v v cc 4 v, i ol = 5 ma, 4 v < v cc 5.5 v, i ol = 10 ma reso ??0.4vi ol = 1.6 ma input leakage current stby , nmi, res , md 2 , md 1 , md 0 |i in |? ?1.0av in = 0.5 v to v cc ?0.5 v port 7 ? ? 1.0 a v in = 0.5 v to av cc ?0.5 v
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 527 of 682 rej09b0353-0300 item symbol min typ max unit test conditions ports 1, 2, 3, 5, 6, 8 to b |i tsi |? ?1.0 av in = 0.5 v to v cc ?0.5 v three-state leakage current (off state) reso ? ? 10.0 a input pull-up mos current ports 2, 5 ?i p 10 ? 300 a v cc = 3.0 v to 5.5 v, v in = 0 v nmi, res c in ? ? 50 pf input capacitance all input pins except nmi and res ??20 v in = 0 v, f = 1 mhz, t a = 25c current dissipation * 2 normal operation i cc * 4 ?15 (3.0 v) 41.5 (5.5 v) ma f = 10 mhz sleep mode ? 10 (3.0 v) 30.5 (5.5 v) ma f = 10 mhz standby mode * 3 ? 0.01 5.0 a t a 50c ? ? 20.0 a 50c < t a ai cc ?1.32.5maav cc = 3.0 v during a/d conversion ?1.7?maav cc = 5.0 v analog power supply current idle ? 0.02 10.0 a ram standby voltage v ram 2.0 ? ? v notes: 1. if the a/d converter is not used, do not leave the av cc and av ss pins open. connect av cc to v cc , and connect av ss to v ss . 2. current dissipation values are for v ih min = v cc ?0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up transistors in the off state. 3. the values are for v ram v cc < 3.0 v, v ih min = v cc 0.9, and v il max = 0.3 v. 4. i cc depends on v cc and f as follows: i cc max = 3.0 (ma) + 0.7 (ma/mhz v) v cc f [normal mode] i cc max = 3.0 (ma) + 0.5 (ma/mhz v) v cc f [sleep mode]
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 528 of 682 rej09b0353-0300 table 18.3 permissible output currents conditions: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min typ max unit ports 1, 2, 5 and b ? ? 10 ma permissible output low current (per pin) other output pins i ol ??2.0 ma total of 27 pins including ports 1, 2, 5 and b ??80 ma total of 23 pins, including ports 8, 9, a and b ??75 * 2 /65 * 1 ma permissible output low current (total) total of all output pins, including the above i ol ? ? 120 ma permissible output high current (per pin) all output pins i oh ??2.0 ma permissible output high current (total) total of all output pins i oh ??40 ma notes: to protect chip reliability, do not exceed the output current values in table 18.3. when driving a darlington pair or led, always insert a current-limiting resistor in the output line, as shown in figures 18.1 and 18.2. 1. the value is for conditions: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v 2. the value is for conditions: v cc = 4.5 v to 5.5 v, av cc = 4.5 v to 5.5 v
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 529 of 682 rej09b0353-0300 lsi port 2 k ? darlington pair figure 18.1 darlington pair drive circuit (example) lsi ports led 600 ? figure 18.2 led drive circuit (example)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 530 of 682 rej09b0353-0300 18.1.3 ac characteristics bus timing parameters are listed in table 18.4. control signal timing parameters are listed in table 18.5. timing parameters of the on-chip supporting modules are listed in table 18.6. table 18.4 bus timing condition a: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 8 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition c: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions clock cycle time t cyc 125 500 100 500 55.5 500 ns clock low pulse width t cl 40 ? 30 ? 17 ? figure 18.7, figure 18.8 clock high pulse width t ch 40 ? 30 ? 17 ? clock rise time t cr ? 20 ? 15 ? 10 clock fall time t cf ? 20 ? 15 ? 10 address delay time t ad ? 60 ? 50 ? 25 address hold time t ah 25 ? 20 ? 10 ? address strobe delay time t asd ? 60 ? 40 ? 25 write strobe delay time t wsd ? 60 ? 50 ? 25 strobe delay time t sd ? 60 ? 50 ? 25 write data strobe pulse width 1 t wsw1 * 85 ? 60 ? 32 ? write data strobe pulse width 2 t wsw2 * 150 ? 110 ? 62 ? address setup time 1 t as1 20 ? 15 ? 10 ? address setup time 2 t as2 80 ? 65 ? 38 ? read data setup time t rds 50 ? 35 ? 15 ? read data hold time t rdh 0 ? 0 ? 0 ?
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 531 of 682 rej09b0353-0300 condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions write data delay time t wdd ? 75 ? 75 ? 55 ns write data setup time 1 t wds1 60 ? 40 ? 10 ? figure 18.7, figure 18.8 write data setup time 2 t wds2 5 ?? 10 ?? 10 ? write data hold time t wdh 25 ? 20 ? 20 ? read data access time 1 t acc1 * ? 120 ? 100 ? 50 read data access time 2 t acc2 * ? 240 ? 200 ? 105 read data access time 3 t acc3 * ? 70 ? 50 ? 20 read data access time 4 t acc4 * ? 180 ? 150 ? 80 precharge time t pch * 85 ? 60 ? 40 ? wait setup time t wts 40 ? 40 ? 25 ? figure 18.9 wait hold time t wth 10 ? 10 ? 5 ? note: * for condition a, the following times depend on the clock cycle time as shown below. t acc1 = 1.5 t cyc ? 68 (ns) t wsw1 = 1.0 t cyc ? 40 (ns) t acc2 = 2.5 t cyc ? 73 (ns) t wsw2 = 1.5 t cyc ? 38 (ns) t acc3 = 1.0 t cyc ? 55 (ns) t pch = 1.0 t cyc ? 40 (ns) t acc4 = 2.0 t cyc ? 70 (ns) for condition b, the following times depend on the clock cycle time as shown below. t acc1 = 1.5 t cyc ? 50 (ns) t wsw1 = 1.0 t cyc ? 40 (ns) t acc2 = 2.5 t cyc ? 50 (ns) t wsw2 = 1.5 t cyc ? 40 (ns) t acc3 = 1.0 t cyc ? 50 (ns) t pch = 1.0 t cyc ? 40 (ns) t acc4 = 2.0 t cyc ? 50 (ns) for condition c, the following times depend on the clock cycle time as shown below. t acc1 = 1.5 t cyc ? 34 (ns) t wsw1 = 1.0 t cyc ? 24 (ns) t acc2 = 2.5 t cyc ? 34 (ns) t wsw2 = 1.5 t cyc ? 22 (ns) t acc3 = 1.0 t cyc ? 36 (ns) t pch = 1.0 t cyc ? 21 (ns) t acc4 = 2.0 t cyc ? 31 (ns)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 532 of 682 rej09b0353-0300 table 18.5 control signal timing condition a: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 8 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition c: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions res setup time t ress 200 ? 200 ? 200 ? ns figure 18.10 res pulse width t resw 10 ? 10 ? 10 ? tcyc mode programming setup time (md 0 , md 1 , md 2 ) t mds 200 ? 200 ? 200 ? ns reso output delay time t resd ? 100 ? 100 ? 100 ns figure 18.11 reso output pulse width t resow 132 ? 132 ? 132 ? tcyc nmi setup time (nmi, irq 0 , irq 1 , irq 4 , irq 5 ) t nmis 200 ? 200 ? 150 ? ns figure 18.12 nmi hold time (nmi, irq 0 , irq 1 , irq 4 , irq 5 ) t nmih 10 ? 10 ? 10 ? interrupt pulse width (nmi, irq 1 , irq 0 when exiting software standby mode) t nmiw 200 ? 200 ? 200 ? clock oscillator settling time at reset (crystal) t osc1 20 ? 20 ? 20 ? ms figure 18.13 clock oscillator settling time in software standby (crystal) t osc2 8 ? 8 ? 7 ? ms figure 17.1
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 533 of 682 rej09b0353-0300 table 18.6 timing of on-chip supporting modules condition a: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 8 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition c: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions itu timer output delay time t tocd ? 100 ? 100 ? 100 ns figure 18.15 timer input setup time t tics 50 ? 50 ? 50 ? timer clock input setup time t tcks 50 ? 50 ? 50 ? figure 18.16 single edge t tckwh 1.5 ? 1.5 ? 1.5 ? t cyc timer clock pulse width both edges t tckwl 2.5 ? 2.5 ? 2.5 ? sci asynchro- nous t scyc 4 ? 4 ? 4 ? figure 18.17 input clock cycle synchro- nous 6 ? 6 ? 6 ? input clock rise time t sckr ? 1.5 ? 1.5 ? 1.5 input clock fall time t sckf ? 1.5 ? 1.5 ? 1.5 input clock pulse width t sckw 0.4 0.6 0.4 0.6 0.4 0.6 t scyc
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 534 of 682 rej09b0353-0300 condition a condition b condition c 8 mhz 10 mhz 18 mhz item symbol min max min max min max unit test conditions sci transmit data delay time t txd ? 100 ? 100 ? 100 ns figure 18.18 receive data setup time (synchronous) t rxs 100 ? 100 ? 100 ? receive data hold time (synchronous clock input) t rxh 100 ? 100 ? 100 ? receive data hold time (synchronous clock output) 0 ? 0 ? 0 ? output data delay time t pwd ? 100 ? 100 ? 100 ns figure 18.14 ports and tpc input data setup time t prs 50 ? 50 ? 50 ? input data hold time t prh 50 ? 50 ? 50 ? cr h 5 v r l this lsi output pin c = 90 pf: ports 1, 2, 3, 5, 6, 8, c = 30 pf: ports 9, a, b input/output timing measurement levels  low: 0.8 v  high: 2.0 v r = 2.4 k r = 12 k l h ? ? figure 18.3 output load circuit
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 535 of 682 rej09b0353-0300 18.1.4 a/d conversion characteristics table 18.7 lists the a/d conversion characteristics. table 18.7 a/d converter characteristics condition a: v cc = 2.7 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 8 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition c: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b condition c 8 mhz 10 mhz 18 mhz item min typ max min typ max min typ max unit resolution 10 10 10 10 10 10 10 10 10 bits conversion time ?? 16.8 ?? 13.4 ?? 7.5 s analog input capacitance ?? 20 ?? 20 ?? 20 pf ?? 10 * 1 ?? 10 * 1 ?? 10 * 4 k ? permissible signal- source impedance ?? 5 * 2 ?? 5 * 3 ?? 5 * 5 nonlinearity error ?? 7.5 ?? 7.5 ?? 3.5 lsb offset error ?? 7.5 ?? 7.5 ?? 3.5 lsb full-scale error ?? 7.5 ?? 7.5 ?? 3.5 lsb quantization error ?? 0.5 ?? 0.5 ?? 0.5 lsb absolute accuracy ?? 8.0 ?? 8.0 ?? 4.0 lsb notes: 1. the value is for 4.0 v av cc 5.5 v. 2. the value is for 2.7 v av cc < 4.0 v. 3. the value is for 3.0 v av cc < 4.0 v. 4. the value is for 12 mhz. 5. the value is for > 12 mhz.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 536 of 682 rej09b0353-0300 18.2 electrical characteristics of flash memory version 18.2.1 absolute maximum ratings table 18.8 lists the absolute maximum ratings. table 18.8 absolute maximum ratings item symbol value unit power supply voltage v cc ? 0.3 to +7.0 v input voltage (except port 7) * 1 v in ? 0.3 to v cc +0.3 v input voltage (port 7) v in ? 0.3 to av cc +0.3 v analog power supply voltage av cc ? 0.3 to +7.0 v analog input voltage v an ? 0.3 to av cc +0.3 v operating temperature t opr regular specifications: ? 20 to +75 * 2 c wide-range specifications: ? 40 to +85 * 2 c storage temperature t stg ? 55 to +125 c caution: permanent damage to the chip may result if absolute maximum ratings are exceeded. notes: 1. 12 v must not be applied to any pin, as this will cause permanent damage to the chip. 2. the operating temperature range when programming/erasing flash memory is t a = 0 to +75 c (regular specifications) or t a = 0 to +85 c (wide-range specifications).
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 537 of 682 rej09b0353-0300 18.2.2 dc characteristics table 18.9 lists the dc characteristics. table 18.10 lists the permissible output currents. table 18.9 dc characteristics (1) conditions: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v* 1 , t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) (programming/erasing conditions: t a = 0c to +75c (regular specifications), t a = 0c to +85c (wide-range specifications)) item symbol min typ max unit test conditions v t ? 1.0 ?? v v t + ?? v cc 0.7 v schmitt trigger input voltages port a, p8 0 to p8 1 , pb 0 to pb 3 v t + ? v t ? 0.4 ?? v res , stby , nmi, md 2 , md 1 , md 0 , fwe v ih v cc ? 0.7 ? v cc +0.3 v extal v cc 0.7 ? v cc +0.3 v port 7 2.0 ? av cc +0.3 v input high voltage ports 1, 2, 3, 5, 6, 9, pb 4 , pb 5 , pb 7 2.0 ? v cc +0.3 v res , stby , md 2 , md 1 , md 0 , fwe v il ? 0.3 ? 0.5 v input low voltage nmi, extal, ports 1, 2, 3, 5, 6, 7, 9, pb 4 , pb 5 , pb 7 ? 0.3 ? 0.8 v all output pins v oh v cc ? 0.5 ?? vi oh = ? 200 a output high voltage 3.5 ?? vi oh = ? 1 ma all output pins v ol ?? 0.4 v i ol = 1.6 ma output low voltage ports 1, 2, 5, b ?? 1.0 v i ol = 10 ma
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 538 of 682 rej09b0353-0300 item symbol min typ max unit test conditions stby , nmi, res , md 2 , md 1 , md 0 |i in | ?? 1.0 a v in = 0.5 v to v cc ? 0.5 v port 7 ?? 1.0 a v in = 0.5 v to av cc ? 0.5 v input leakage current fwe ?? 10 three-state leakage current (off state) ports 1, 2, 3, 5, 6, 8, 9, a, b |i tsi | ?? 1.0 a v in = 0.5 v to v cc ? 0.5 v input pull-up current ports 2, 5 ? i p 50 ? 300 a v in = 0 v nmi, res c in ?? 50 pf input capacitance all input pins except nmi and res ?? 20 v in = 0 v, f = 1 mhz, t a = 25 c normal operation i cc ? 50 70 ma f = 18 mhz sleep mode ? 35 50 f = 18 mhz ? 0.01 5.0 a t a 50 c current dissipation * 2 * 4 standby mode * 3 ?? 20.0 50 c < t a during a/d conversion ai cc ? 1.7 2.8 ma analog power supply current idle ? 0.02 10.0 a ram standby voltage v ram 2.0 ?? v notes: 1. if the a/d converter is not used, do not leave the av cc and av ss pins open. connect av cc to v cc , and connect av ss to v ss . 2. current dissipation values are for v ih min = v cc ? 0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up transistors in the off state. 3. the values are for v ram v cc < 4.5 v, v ih min = v cc 0.9, and v il max = 0.3 v. 4. power supply current value when programming/erasing in flash memory (t a = 0 c to +75 c (regular specifications), t a = 0 c to +85 c (wide-range specifications)) is 20 ma (max) higher than the power supply current value in normal operation.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 539 of 682 rej09b0353-0300 table 18.9 dc characteristics (2) conditions: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v* 1 , t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) (programming/erasing conditions: v cc = 3.0 v to 3.6 v, t a = 0c to +75c (regular specifications), t a = 0c to +85c (wide-range specifications)) item symbol min typ max unit test conditions v t ? v cc 0.2 ?? v v t + ?? v cc 0.7 v schmitt trigger input voltages port a, p8 0 to p8 1 , pb 0 to pb 3 v t + ? v t ? v cc 0.04 ?? v input high voltage res , stby , nmi, md 2 to md 0 , fwe v ih v cc 0.9 ? v cc +0.3 v extal v cc 0.7 ? v cc +0.3 v port 7 v cc 0.7 ? av cc +0.3 v ports 1 to 3, 5, 6, 9, pb 4 , pb 5 , pb 7 v cc 0.7 ? v cc +0.3 v input low voltage res , stby , fwe, md 2 to md 0 , fwe v il ? 0.3 ? v cc 0.1 v ? 0.3 ? v cc 0.2 v v cc < 4.0 v nmi, extal, ports 1 to 3, 5 to 7, 9, pb 4 , pb 5 , pb 7 0.8 v cc = 4.0 v to 5.5v output high voltage all output pins v oh v cc ? 0.5 v cc ? 1.0 ? ? ? ? v v i oh = ? 200 a i oh = ? 1 ma all output pins v ol ?? 0.4 v i ol = 1.0 ma output low voltage ports 1, 2, 5, b ?? 1.0 v v cc 4 v, i ol = 5 ma, 4v < v cc 5.5 v, i ol = 10 ma
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 540 of 682 rej09b0353-0300 item symbol min typ max unit test conditions stby , nmi, res , md 2 , md 1 , md 0 |i in | ?? 1.0 a v in = 0.5 v to v cc ? 0.5 v input leakage current port 7 ?? 1.0 a v in = 0.5 v to av cc ? 0.5 v fwe ?? 10 a v in = 0.5 v to v cc ? 0.5 v three-state leakage current (off state) ports 1, 2, 3, 5, 6, 8 to b |i tsi | ?? 1.0 a v in = 0.5 v to v cc ? 0.5 v input pull-up current ports 2 and 5 ? i p 10 ? 300 a v cc = 3.0 v to 5.5 v, v in = 0 v nmi, res c in ?? 50 pf input capacitance all input pins except nmi and res ?? 20 pf v in = 0 v, f = 1 mhz, t a = 25 c normal operation i cc * 4 ? 15 (3.0 v) 41.5 (5.5 v) ma f = 10 mhz current dissipation * 2 * 5 sleep mode ? 10 (3.0 v) 30.5 (5.5 v) ma f = 10 mhz standby mode * 3 ? 0.01 5.0 a t a 50 c ?? 20.0 50 c < t a ai cc ? 1.3 2.5 ma av cc = 3.0 v during a/d conversion ? 1.7 2.8 av cc = 5.0 v analog power supply current idel ? 0.02 10.0 a ram standby voltage v ram 2.0 ?? v notes: 1. if the a/d converter is not used, do not leave the av cc and av ss pins open. connect av cc to v cc , and connect av ss to v ss . 2. current dissipation values are for v ih min = vcc ? 0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up transistors in the off state. 3. the values are for v ram v cc < 3.0 v, v ih min = vcc 0.9, and v il max = 0.3 v. 4. i cc depends on v cc and f as follows: i cc max = 3.0 (ma) + 0.7 (ma/mhz ? v) v cc f [normal mode] i cc max = 3.0 (ma) + 0.5 (ma/mhz ? v) v cc f [sleep mode] 5. the current dissipation value when programming/erasing flash memory (t a = 0 c to +75 c (regular specifications), t a = 0 c to +85 c (wide-range specifications)) is 20 ma (max) higher than the current dissipation value in normal operation.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 541 of 682 rej09b0353-0300 table 18.10 permissible output currents conditions: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) item symbol min typ max unit permissible output low current (per pin) ports 1, 2, 5 and b i ol ?? 10 ma other output pins ?? 2.0 ma permissible output low current (total) total of 27 pins including ports 1, 2, 5 and b i ol ?? 80 ma total of 23 pins, including ports 8, 9, a and b ?? 75 * 2 / 65 * 1 ma total of all output pins, including the above ?? 120 ma permissible output high current (per pin) all output pins i oh ?? 2.0 ma permissible output high current (total) total of all output pins i oh ?? 40 ma notes: to protect chip reliability, do not exceed the output current values in table 18.10. when driving a darlington pair or led, always insert a current-limiting resistor in the output line, as shown in figures 18.4 and 18.5. 1. conditions: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v 2. conditions: v cc = 4.5 v to 5.5 v, av cc = 4.5 v to 5.5 v
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 542 of 682 rej09b0353-0300 lsi port 2 k ? darlington pair figure 18.4 darlington pair drive circuit (example) lsi ports led 600 ? figure 18.5 led drive circuit (example)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 543 of 682 rej09b0353-0300 18.2.3 ac characteristics bus timing parameters are listed in table 18.11. control signal timing parameters are listed in table 18.12. timing parameters of the on-chip supporting modules are listed in table 18.13. table 18.11 bus timing condition a: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b 10 mhz 18 mhz item symbol min max min max unit test conditions clock cycle time t cyc 100 500 55.5 500 ns clock low pulse width t cl 30 ? 17 ? figure 18.7, figure 18.8 clock high pulse width t ch 30 ? 17 ? clock rise time t cr ? 15 ? 10 clock fall time t cf ? 15 ? 10 address delay time t ad ? 50 ? 25 address hold time t ah 20 ? 10 ? address strobe delay time t asd ? 40 ? 25 write strobe delay time t wsd ? 50 ? 25 strobe delay time t sd ? 50 ? 25 write data strobe pulse width 1 t wsw1 * 60 ? 32 ? write data strobe pulse width 2 t wsw2 * 110 ? 62 ? address setup time 1 t as1 15 ? 10 ? address setup time 2 t as2 65 ? 38 ? read data setup time t rds 35 ? 15 ? read data hold time t rdh 0 ? 0 ?
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 544 of 682 rej09b0353-0300 condition a condition b 10 mhz 18 mhz item symbol min max min max unit test conditions write data delay time t wdd ? 75 ? 55 ns write data setup time 1 t wds1 40 ? 10 ? figure 18.7, figure 18.8 write data setup time 2 t wds2 ? 10 ?? 10 ? write data hold time t wdh 20 ? 20 ? read data access time 1 t acc1 * ? 100 ? 50 read data access time 2 t acc2 * ? 200 ? 105 read data access time 3 t acc3 * ? 50 ? 20 read data access time 4 t acc4 * ? 150 ? 80 precharge time t pch * 60 ? 40 ? wait setup time t wts 40 ? 25 ? ns figure 18.9 wait hold time t wth 10 ? 5 ? note: * for condition a, the following times depend on the clock cycle time as shown below. t acc1 = 1.5 t cyc ? 50 (ns) t wsw1 = 1.0 t cyc ? 40 (ns) t acc2 = 2.5 t cyc ? 50 (ns) t wsw2 = 1.5 t cyc ? 40 (ns) t acc3 = 1.0 t cyc ? 50 (ns) t pch = 1.0 t cyc ? 40 (ns) t acc4 = 2.0 t cyc ? 50 (ns) for condition b, the following times depend on the clock cycle time as shown below. t acc1 = 1.5 t cyc ? 34 (ns) t wsw1 = 1.0 t cyc ? 24 (ns) t acc2 = 2.5 t cyc ? 34 (ns) t wsw2 = 1.5 t cyc ? 22 (ns) t acc3 = 1.0 t cyc ? 36 (ns) t pch = 1.0 t cyc ? 21 (ns) t acc4 = 2.0 t cyc ? 31 (ns)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 545 of 682 rej09b0353-0300 table 18.12 control signal timing condition a: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition b: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b 10 mhz 18 mhz item symbol min max min max unit test conditions res setup time t ress 200 ? 200 ? ns figure 18.10 res pulse width t resw 20 ? 20 ? tcyc mode programming setup time t mds 200 ? 200 ? ns nmi setup time (nmi, irq 0 , irq 1 , irq 4 , irq 5 ) t nmis 200 ? 150 ? ns figure 18.12 nmi hold time (nmi, irq 0 , irq 1 , irq 4 , irq 5 ) t nmih 10 ? 10 ? interrupt pulse width (nmi, irq 1 , irq 0 when exiting software standby mode) t nmiw 200 ? 200 ? clock oscillator settling time at reset (crystal) t osc1 20 ? 20 ? ms figure 18.13 clock oscillator settling time in software standby (crystal) t osc2 8 ? 7 ? ms figure 17.1
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 546 of 682 rej09b0353-0300 table 18.13 timing of on-chip supporting modules condition a: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b 10 mhz 18 mhz item symbol min max min max unit test conditions itu timer output delay time t tocd ? 100 ? 100 ns figure 18.15 timer input setup time t tics 50 ? 50 ? timer clock input setup time t tcks 50 ? 50 ? figure 18.16 single edge t tckwh 1.5 ? 1.5 ? t cyc timer clock pulse width both edges t tckwl 2.5 ? 2.5 ? sci asynchro- nous t scyc 4 ? 4 ? figure 18.17 input clock cycle synchro- nous 6 ? 6 ? input clock rise time t sckr ? 1.5 ? 1.5 input clock fall time t sckf ? 1.5 ? 1.5 input clock pulse width t sckw 0.4 0.6 0.4 0.6 t scyc transmit data delay time t txd ? 100 ? 100 ns figure 18.18 receive data setup time (synchronous) t rxs 100 ? 100 ? receive data hold time (synchronous clock input) t rxh 100 ? 100 ? receive data hold time (synchronous clock output) 0 ? 0 ?
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 547 of 682 rej09b0353-0300 condition a condition b 10 mhz 18 mhz item symbol min max min max unit test conditions output data delay time t pwd ? 100 ? 100 ns figure 18.14 input data setup time t prs 50 ? 50 ? ports and tpc input data hold time t prh 50 ? 50 ? cr h 5 v r l this lsi output pin c = 90 pf: ports 1, 2, 3, 5, 6, 8, c = 30 pf: ports 9, a, b input/output timing measurement levels  low: 0.8 v  high: 2.0 v r = 2.4 k r = 12 k l h ? ? figure 18.6 output load circuit
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 548 of 682 rej09b0353-0300 18.2.4 a/d conversion characteristics table 18.14 lists the a/d conversion characteristics. table 18.14 a/d converter characteristics condition a: v cc = 3.0 v to 5.5 v, av cc = 3.0 v to 5.5 v, v ss = av ss = 0 v, = 2 mhz to 10 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide- range specifications) condition b: v cc = 5.0 v 10 % , av cc = 5.0 v 10 % , v ss = av ss = 0 v, = 2 mhz to 18 mhz, t a = ?20c to +75c (regular specifications), t a = ?40c to +85c (wide-range specifications) condition a condition b 10 mhz 18 mhz item min typ max min typ max unit resolution 10 10 10 10 10 10 bits conversion time ?? 13.4 ?? 7.5 s analog input capacitance ?? 20 ?? 20 pf ?? 5 * 1 ?? 10 * 2 k ? permissible signal- source impedance ?? 5 * 3 nonlinearity error ?? 7.5 ?? 3.5 lsb offset error ?? 7.5 ?? 3.5 lsb full-scale error ?? 7.5 ?? 3.5 lsb quantization error ?? 0.5 ?? 0.5 lsb absolute accuracy ?? 8.0 ?? 4.0 lsb notes: 1. the value is for = 10 mhz. 2. the value is for 12 mhz. 3. the value is for > 12 mhz.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 549 of 682 rej09b0353-0300 18.2.5 flash memory characteristics table 18.15 shows the flash memory characteristics. table 18.15 flash memory characteristics (1) conditions: v cc = 4.5 v to 5.5 v, av cc = 4.5 v to 5.5 v, v ss = av ss = 0 v t a = 0c to +75c (program/erase operating temperature range: regular specifications), t a = 0c to +85c (program/erase operating temperature range: wide-range specifications) item symbol min typ max unit test condition programming time * 1 * 2 * 4 t p ? 10 200 ms/32 bytes erase time * 1 * 3 * 5 t e ? 100 300 ms/block reprogramming count n wec ?? 100 times programming wait time after swe bit setting * 1 x10 ?? s wait time after psu bit setting * 1 y50 ?? s wait time after p bit setting * 1 * 4 z 150 ? 500 s wait time after p bit clear * 1 10 ?? s wait time after psu bit clear * 1 10 ?? s wait time after pv bit setting * 1 4 ?? s wait time after h'ff dummy write * 1 2 ?? s wait time after pv bit clear * 1 4 ?? s maximum programming count * 1 * 4 n ?? 403 times erase wait time after swe bit setting * 1 x10 ?? s wait time after esu bit setting * 1 y 200 ?? s wait time after e bit setting * 1 * 5 z5 ? 10 ms wait time after e bit clear * 1 10 ?? s wait time after esu bit clear * 1 10 ?? s wait time after ev bit setting * 1 20 ?? s wait time after h'ff dummy write * 1 2 ?? s wait time after ev bit clear * 1 5 ?? s maximum erase count * 1 * 5 n30 ? 60 times notes: 1. set the times according to the program/erase algorithms. 2. programming time per 32 bytes (shows the total time the flash memory control register (flmcr) is set. it does not include the programming verification time.)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 550 of 682 rej09b0353-0300 3. block erase time (shows the period the e bit in flmcr is set. it does not include the erase verification time.) 4. to specify the maximum programming time (t p (max)) in the 32-byte programming flowchart, set the max value (403) for the maximum programming count (n). the wait time after p bit setting (z) should be changed as follows according to the programming counter value. programming counter value of 1 to 4: z = 150 s programming counter value of 5 to 403: z = 500 s 5. for the maximum erase time (t e (max)), the following relationship applies between the wait time after e bit setting (z) and the maximum erase count (n): t e (max) = wait time after e bit setting (z) maximum erase count (n) to set the maximum erase time, the values of z and n should be set so as to satisfy the above formula. examples: when z = 5 [ms]: n = 60 times when z = 10 [ms]: n = 30 times
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 551 of 682 rej09b0353-0300 table 18.15 flash memory characteristics (2) conditions: v cc = 3.0 v to 3.6 v, av cc = 3.0 v to 3.6 v, v ss = av ss = 0 v t a = 0c to +75c (programming/erasing operating temperature range: regular specification) t a = 0c to +85c (programming/erasing operating temperature range: wide-range specification) item symbol min typ max unit test condition programming time * 1 * 2 * 4 t p ? 10 200 ms/32 bytes erase time * 1 * 3 * 5 t e ? 100 300 ms/block reprogramming count n wec ?? 100 times programming wait time after swe bit setting * 1 x10 ?? s wait time after psu bit setting * 1 y50 ?? s wait time after p bit setting * 1 * 4 z 150 ? 500 s wait time after p bit clear * 1 10 ?? s wait time after psu bit clear * 1 10 ?? s wait time after pv bit setting * 1 4 ?? s wait time after h'ff dummy write * 1 2 ?? s wait time after pv bit clear * 1 4 ?? s maximum programming count * 1, * 4 n ?? 403 times erase wait time after swe bit setting * 1 x10 ?? s wait time after esu bit setting * 1 y 200 ?? s wait time after e bit setting * 1 * 5 z5 ? 10 ms wait time after e bit clear * 1 10 ?? s wait time after esu bit clear * 1 10 ?? s wait time after ev bit setting * 1 20 ?? s wait time after h'ff dummy write * 1 2 ?? s wait time after ev bit clear * 1 5 ?? s maximum erase count * 1 * 5 n30 ? 60 times notes: 1. make each time setting in accordance with the program/program-verify flowchart or erase/erase-verify flowchart. 2. programming time per 32 bytes (shows the total period for which the p-bit in the flash memory control register (flmcr) is set. it does not include the programming verification time.) 3. block erase time (shows the total period for which the e-bit in flmcr is set. it does not include the erase verification time.)
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 552 of 682 rej09b0353-0300 4. to specify the maximum programming time (t p (max)) in the 32-byte programming flowchart, set the maximum value (403) for the maximum programming count (n). the wait time after p bit setting (z) should be changed as follows according to the programming counter value. programming counter value of 1 to 4: z = 150 s programming counter value of 5 to 403: z = 500 s 5. for the maximum erase time (t e (max)), the following relationship applies between the wait time after e bit setting (z) and the maximum erase count (n): t e (max) = wait time after e bit setting (z) maximum erase count (n) to set the maximum erase time, the values of z and n should be set so as to satisfy the above formula. examples: when z = 5 [ms], n = 60 times when z = 10 [ms], n = 30 times 18.3 operational timing this section shows timing diagrams. 18.3.1 bus timing bus timing is shown as follows: ? basic bus cycle: two-state access figure 18.7 shows the timing of the external two-state access cycle. ? basic bus cycle: three-state access figure 18.8 shows the timing of the external three-state access cycle. ? basic bus cycle: three-state access with one wait state figure 18.9 shows the timing of the external three-state access cycle with one wait state inserted.
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 553 of 682 rej09b0353-0300 t 1 t 2 t cyc t ch t cl t ad t cf t cr t as1 t as1 t asd t acc3 t asd t acc3 t acc1 t asd t as1 t wdd t wds1 t wsw1 t sd t ah t pch t sd t ah t pch t rdh t rds t pch t sd t ah t wdh a 23 to a 0 as rd (read) d 7 to d 0 (read) wr (write) d 7 to d 0 (write) figure 18.7 basic bus cycle: two-state access
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 554 of 682 rej09b0353-0300 t 1 t 2 t 3 t acc4 t acc4 t acc2 t wsw2 t wsd t as2 t wds2 a 23 to a 0 as rd (read) d 7 to d 0 (read) wr (write) d 7 to d 0 (write) t rds figure 18.8 basic bus cycle: three-state access
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 555 of 682 rej09b0353-0300 t 1 t 2 t w t 3 t wts t wts t wth a 23 to a 0 as rd (read) d 7 to d 0 (read) wr (write) d 7 to d 0 (write) wait t wth figure 18.9 basic bus cycle: three-state access with one wait state
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 556 of 682 rej09b0353-0300 18.3.2 control signal timing control signal timing is shown as follows: ? reset input timing figure 18.10 shows the reset input timing. ? reset output timing figure 18.11 shows the reset output timing. ? interrupt input timing figure 18.12 shows the interrupt input timing for nmi and irq 5 , irq 4 , irq 1 , and irq 0 . res t ress t ress t resw t mds md2 to md0 fwe * note: * the fwe input timing shown is for entering and exiting boot mode. figure 18.10 reset input timing reso * note: * flash version does not have reso output pin t resd t resow t resd figure 18.11 reset output timing
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 557 of 682 rej09b0353-0300 nmi irq irq e l t nmis t nmih t nmis t nmih t nmis t nmiw nmi irq j irq : edge-sensitive irq : level-sensitive irq (i = 0, 1, 4, and 5) e l i i irq (j = 0, 1) figure 18.12 interrupt input timing
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 558 of 682 rej09b0353-0300 18.3.3 clock timing clock timing is shown below. ? oscillator settling timing figure 18.13 shows the oscillator settling timing. v cc stby res t osc1 t osc1 figure 18.13 oscillator settling timing 18.3.4 tpc and i/o port timing tpc and i/o port timing is shown below. t 1 t 2 t 3 ports 1 to 3, 5 to 9, a, and b (read) ports 1 to 3, 5, 6, 8, 9, a, and b (write) t prs t prh t pwd figure 18.14 tpc and i/o port input/output timing
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 559 of 682 rej09b0353-0300 18.3.5 itu timing itu timing is shown as follows: ? itu input/output timing figure 18.15 shows the itu input/output timing. ? itu external clock input timing figure 18.16 shows the itu external clock input timing. output compare * 1 input capture * 2 t tocd t tics notes: 1. tioca 0 to tioca 4 , tiocb 0 to tiocb 4 , tocxa 4 , tocxb 4 2. tioca 0 to tioca 4 , tiocb 0 to tiocb 4 figure 18.15 itu input/output timing t tcks t tcks t tckwh t tckwl tclka to tclkd figure 18.16 itu external clock input timing
section 18 electrical characteristics rev.3.00 mar. 26, 2007 page 560 of 682 rej09b0353-0300 18.3.6 sci input/output timing sci timing is shown as follows: ? sci input clock timing figure 18.17 shows the sci input clock timing. ? sci input/output timing (synchronous mode) figure 18.18 shows the sci input/output timing in synchronous mode. sck t sckw t scyc t sckr t sckf figure 18.17 sck input clock timing t scyc t txd t rxs t rxh sck txd (transmit data) rxd (receive data) figure 18.18 sci input/output timing in synchronous mode
appendix a instruction set rev.3.00 mar. 26, 2007 page 561 of 682 rej09b0353-0300 appendix a instruction set a.1 instruction list operand notation symbol description rd general destination register * rs general source register * rn general register * erd general destination register (address register or 32-bit register) ers general source register (address register or 32-bit register) ern general register (32-bit register) (ead) destination operand (eas) source operand pc program counter sp stack pointer ccr condition code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr disp displacement transfer from the operand on the left to the operand on the right, or transition from the state on the left to the state on the right + addition of the operands on both sides ? subtraction of the operand on the right from the operand on the left multiplication of the operands on both sides division of the operand on the left by the operand on the right logical and of the operands on both sides  logical or of the operands on both sides exclusive logical or of the operands on both sides ? not (logical complement) ( ), < > contents of operand note: * general registers include 8-bit registers (r0h to r7h and r0l to r7l) and 16-bit registers (r0 to r7 and e0 to e7).
appendix a instruction set rev.3.00 mar. 26, 2007 page 562 of 682 rej09b0353-0300 condition code notation symbol description ? changed according to execution result * undetermined (no guaranteed value) 0 cleared to 0 1 set to 1 ? not affected by execution of the instruction ? varies depending on conditions, described in notes
appendix a instruction set rev.3.00 mar. 26, 2007 page 563 of 682 rej09b0353-0300 table a.1 instruction set 1. data transfer instructions condition code mnemonic operation i h n z v c mov.b #xx:8, rd b #xx:8 rd8 2 ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 ? 2 mov.b rs, rd b rs8 rd8 2 ?? 0 ? 2 mov.b @ers, rd b @ers rd8 2 ?? 0 ? 4 mov.b @(d:16, ers), b @(d:16, ers) rd8 4 ?? 0 ? 6 rd mov.b @(d:24, ers), b @(d:24, ers) rd8 8 ?? 0 ? 10 rd mov.b @ers+, rd b @ers rd8 2 ?? 0 ? 6 ers32+1 ers32 mov.b @aa:8, rd b @aa:8 rd8 2 ?? 0 ? 4 mov.b @aa:16, rd b @aa:16 rd8 4 ?? 0 ? 6 mov.b @aa:24, rd b @aa:24 rd8 6 ?? 0 ? 8 mov.b rs, @erd b rs8 @erd 2 ?? 0 ? 4 mov.b rs, @(d:16, b rd8 @(d:16, erd) 4 ?? 0 ? 6 erd) mov.b rs, @(d:24, b rd8 @(d:24, erd) 8 ?? 0 ? 10 erd) mov.b rs, @ ? erd b erd32 ? 1 erd32 2 ?? 0 ? 6 rs8 @erd mov.b rs, @aa:8 b rs8 @aa:8 2 ?? 0 ? 4 mov.b rs, @aa:16 b rs8 @aa:16 4 ?? 0 ? 6 mov.b rs, @aa:24 b rs8 @aa:24 6 ?? 0 ? 8 mov.w #xx:16, rd w #xx:16 rd16 4 ?? 0 ? 4 mov.w rs, rd w rs16 rd16 2 ?? 0 ? 2 mov.w @ers, rd w @ers rd16 2 ?? 0 ? 4 mov.w @(d:16, ers), w @(d:16, ers) rd16 4 ?? 0 ? 6 rd mov.w @(d:24, ers), w @(d:24, ers) rd16 8 ?? 0 ? 10 rd mov.w @ers+, rd w @ers rd16 2 ?? 0 ? 6 ers32+2 @erd32 mov.w @aa:16, rd w @aa:16 rd16 4 ?? 0 ? 6 #xx rn @ern @(d, ern) @?ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size
appendix a instruction set rev.3.00 mar. 26, 2007 page 564 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c mov.w @aa:24, rd w @aa:24 rd16 6 ?? 0 ? 8 mov.w rs, @erd w rs16 @erd 2 ?? 0 ? 4 mov.w rs, @(d:16, w rs16 @(d:16, erd) 4 ?? 0 ? 6 erd) mov.w rs, @(d:24, w rs16 @(d:24, erd) 8 ?? 0 ? 8 erd) mov.w rs, @ ? erd w erd32 ? 2 erd32 2 ?? 0 ? 6 rs16 @erd mov.w rs, @aa:16 w rs16 @aa:16 4 ?? 0 ? 6 mov.w rs, @aa:24 w rs16 @aa:24 6 ?? 0 ? 8 mov.l #xx:32, rd l #xx:32 rd32 6 ?? 0 ? 6 mov.l ers, erd l ers32 erd32 2 ?? 0 ? 2 mov.l @ers, erd l @ers erd32 4 ?? 0 ? 8 mov.l @(d:16, ers), l @(d:16, ers) erd32 6 ?? 0 ? 10 erd mov.l @(d:24, ers), l @(d:24, ers) erd32 10 ?? 0 ? 14 erd mov.l @ers+, erd l @ers erd32 4 ? ? 0 ? 10 ers32+4 ers32 mov.l @aa:16, erd l @aa:16 erd32 6 ?? 0 ? 10 mov.l @aa:24, erd l @aa:24 erd32 8 ? ? 0 ? 12 mov.l ers, @erd l ers32 @erd 4 ? ? 0 ? 8 mov.l ers, @(d:16, l ers32 @(d:16, erd) 6 ?? 0 ? 10 erd) mov .l ers, @(d:24, l ers32 @(d:24, erd) 10 ?? 0 ? 14 erd) mov .l ers, @ ? erd l erd32 ? 4 erd32 4 ?? 0 ? 10 ers32 @erd mov .l ers, @aa:16 l ers32 @aa:16 6 ?? 0 ? 10 mov .l ers, @aa:24 l ers32 @aa:24 8 ?? 0 ? 12 pop .w rn w @sp rn16 2 ?? 0 ? 6 sp+2 sp pop .l ern l @sp ern32 4 ?? 0 ? 10 sp+4 sp #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 565 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c push.w rn w sp ? 2 sp 2 ?? 0 ? 6 rn16 @sp push.l ern l sp ? 4 sp 4 ?? 0 ? 10 ern32 @sp movfpe @aa:16, b cannot be used in the 4 cannot be used in the h8/3039 rd h8/3039 group group movtpe rs, b cannot be used in the 4 cannot be used in the h8/3039 @aa:16 h8/3039 group group #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 566 of 682 rej09b0353-0300 2. arithmetic instructions condition code mnemonic operation i hnzvc add.b #xx:8, rd b rd8+#xx:8 rd8 2 ? 2 add.b rs, rd b rd8+rs8 rd8 2 ? 2 add.w #xx:16, rd w rd16+#xx:16 rd16 4 ? (1) 4 add.w rs, rd w rd16+rs16 rd16 2 ? (1) 2 add.l #xx:32, erd l erd32+#xx:32 6 ? (2) 6 erd32 add.l ers, erd l erd32+ers32 2 ? (2) 2 erd32 addx.b #xx:8, rd b rd8+#xx:8 +c rd8 2 ? (3) 2 addx.b rs, rd b rd8+rs8 +c rd8 2 ? (3) 2 adds.l #1, erd l erd32+1 erd32 2 ?????? 2 adds.l #2, erd l erd32+2 erd32 2 ?????? 2 adds.l #4, erd l erd32+4 erd32 2 ?????? 2 inc.b rd b rd8+1 rd8 2 ?? ? 2 inc.w #1, rd w rd16+1 rd16 2 ?? ? 2 inc.w #2, rd w rd16+2 rd16 2 ?? ? 2 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 567 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c inc.l #1, erd l erd32+1 erd32 2 ?? ? 2 inc.l #2, erd l erd32+2 erd32 2 ?? ? 2 daa rd b rd8 decimal adjust 2 ? ** ? 2 rd8 sub.b rs, rd b rd8 ? rs8 rd8 2 ? 2 sub.w #xx:16, rd w rd16 ? #xx:16 rd16 4 ? (1) 4 sub.w rs, rd w rd16 ? rs16 rd16 2 ? (1) 2 sub.l #xx:32, erd l erd32 ? #xx:32 6 ? (2) 6 erd32 sub.l ers, erd l erd32 ? ers32 2 ? (2) 2 erd32 subx.b #xx:8, rd b rd8 ? #xx:8 ? c rd8 2 ? (3) 2 subx.b rs, rd b rd8 ? rs8 ? c rd8 2 ? (3) 2 subs.l #1, erd l erd32 ? 1 erd32 2 ?????? 2 subs.l #2, erd l erd32 ? 2 erd32 2 ?????? 2 subs.l #4, erd l erd32 ? 4 erd32 2 ? ????? 2 dec.b rd b rd8 ? 1 rd8 2 ? ? ? 2 dec.w #1, rd w rd16 ? 1 rd16 2 ? ? ? 2 dec.w #2, rd w rd16 ? 2 rd16 2 ? ? ? 2 dec.l #1, erd l erd32 ? 1 erd32 2 ?? ? 2 dec.l #2, erd l erd32 ? 2 erd32 2 ? ? ? 2 das.rd b rd8 decimal adjust 2 ? ** ? 2 rd8 mulxu. b rs, rd b rd8 rs8 rd16 2 ?????? 14 (unsigned multiplication) mulxu. w rs, erd w rd16 rs16 erd32 2 ?????? 22 (unsigned multiplication) mulxs. b rs, rd b rd8 rs8 rd16 4 ?? ? ? 16 (signed multiplication) mulxs. w rs, erd w rd16 rs16 erd32 4 ?? ? ? 24 (signed multiplication) divxu. b rs, rd b rd16 rs8 rd16 2 ?? (6) (7) ?? 14 (rdh: remainder , rdl: quotient) (unsigned division ) #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 568 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c divxu. w rs, erd w erd32 rs16 erd32 2 ?? (6) (7) ?? 22 (ed: remainder, rd: quotient) (unsigned division) divxs. b rs, rd b rd16 rs8 rd16 4 ?? (8) (7) ?? 16 (rdh: remainder, rdl: quotient) (signed division) divxs. w rs, erd w erd32 rs16 erd32 4 ?? (8) (7) ?? 24 (ed: remainder, rd: quotient) (signed division) cmp.b #xx:8, rd b rd8 ? #xx:8 2 ? 2 cmp.b rs, rd b rd8 ? rs8 2 ? 2 cmp.w #xx:16, rd w rd16 ? #xx:16 4 ? (1) 4 cmp.w rs, rd w rd16 ? rs16 2 ? (1) 2 cmp.l #xx:32, erd l erd32 ? #xx:32 6 ? (2) 4 cmp.l ers, erd l erd32 ? ers32 2 ? (2) 2 neg.b rd b 0 ? rd8 rd8 2 ? 2 neg.w rd w 0 ? rd16 rd16 2 ? 2 neg.l erd l 0 ? erd32 erd32 2 ? 2 extu.w rd w 0 ( 2 ? ? 0 0 ? 2 of rd16) extu.l erd l 0 ( 2 ? ? 0 0 ? 2 of rd32) exts.w rd w ( of rd16) 2 ?? 0 ? 2 ( of rd16) exts.l erd l ( of rd32) 2 ?? 0 ? 2 ( of erd32) #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 569 of 682 rej09b0353-0300 3. logic instructions condition code mnemonic operation i h n z v c and.b #xx:8, rd b rd8 #xx:8 rd8 2 ?? 0 ? 2 and.b rs, rd b rd8 rs8 rd8 2 ?? 0 ? 2 and.w #xx:16, rd w rd16 #xx:16 rd16 4 ?? 0 ? 4 and.w rs, rd w rd16 rs16 rd16 2 ?? 0 ? 2 and.l #xx:32, erd l erd32 #xx:32 erd32 6 ?? 0 ? 6 and.l ers, erd l erd32 ers32 erd32 4 ?? 0 ? 4 or.b #xx:8, rd b rd8 #xx:8 rd8 2 ?? 0 ? 2 or.b rs, rd b rd8 rs8 rd8 2 ?? 0 ? 2 or.w #xx:16, rd w rd16 #xx:16 rd16 4 ?? 0 ? 4 or.w rs, rd w rd16 rs16 rd16 2 ?? 0 ? 2 or.l #xx:32, erd l erd32 #xx:32 erd32 6 ?? 0 ? 6 or.l ers, erd l erd32 ers32 erd32 4 ?? 0 ? 4 xor.b #xx:8, rd b rd8 #xx:8 rd8 2 ?? 0 ? 2 xor.b rs, rd b rd8 rs8 rd8 2 ? ? 0 ? 2 xor.w #xx:16, rd w rd16 #xx:16 rd16 4 ? ? 0 ? 4 xor.w rs, rd w rd16 rs16 rd16 2 ? ? 0 ? 2 xor.l #xx:32, erd l erd32 #xx:32 erd32 6 ? ? 0 ? 6 xor.l ers, erd l erd32 ers32 erd32 4 ? ? 0 ? 4 not.b rd b ? rd8 rd8 2 ?? 0 ? 2 not.w rd w ? rd16 rd16 2 ? ? 0 ? 2 not.l erd l ? rd32 rd32 2 ?? 0 ? 2 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 570 of 682 rej09b0353-0300 4. shift instructions condition code mnemonic operation i h n z v c shal.b rd b 2 ?? 2 shal.w rd w 2 ?? 2 shal.l erd l 2 ?? 2 shar.b rd b 2 ?? 02 shar.w rd w 2 ?? 02 shar.l erd l 2 ?? 02 shll.b rd b 2 ?? 02 shll.w rd w 2 ?? 02 shll.l erd l 2 ?? 02 shlr.b rd b 2 ?? 02 shlr.w rd w 2 ?? 02 shlr.l erd l 2 ?? 02 rotxl.b rd b 2 ?? 02 rotxl.w rd w 2 ?? 02 rotxl.l erd l 2 ?? 02 rotxr.b rd b 2 ?? 02 rotxr.w rd w 2 ?? 02 rotxr.l erd l 2 ?? 02 rotl.b rd b 2 ?? 02 rotl.w rd w 2 ?? 02 rotl.l erd l 2 ?? 02 rotr.b rd b2 ?? 02 rotr.w rd w2 ?? 02 rotr.l erd l 2 ?? 02 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size msb lsb 0 c c msb lsb msb lsb 0 c 0 c msb lsb c msb lsb c msb lsb c msb lsb c msb lsb ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 571 of 682 rej09b0353-0300 5. bit manipulation instructions condition code mnemonic operation i h n z v c bset #xx:3, rd b (#xx:3 of rd8) 12 ?????? 2 bset #xx:3, @erd b (#xx:3 of @erd) 14 ?????? 8 bset #xx:3, @aa:8 b (#xx:3 of @aa:8) 14 ?????? 8 bset rn, rd b (rn8 of rd8) 12 ?????? 2 bset rn, @erd b (rn8 of @erd) 14 ?????? 8 bset rn, @aa:8 b (rn8 of @aa:8) 14 ?????? 8 bclr #xx:3, rd b (#xx:3 of rd8) 02 ?????? 2 bclr #xx:3, @erd b (#xx:3 of @erd) 04 ?????? 8 bclr #xx:3, @aa:8 b (#xx:3 of @aa:8) 04 ?????? 8 bclr rn, rd b (rn8 of rd8) 02 ?????? 2 bclr rn, @erd b (rn8 of @erd) 04 ?????? 8 bclr rn, @aa:8 b (rn8 of @aa:8) 04 ?????? 8 bnot #xx:3, rd b (#xx:3 of rd8) 2 ?????? 2 ? (#xx:3 of rd8) bnot #xx:3, @erd b (#xx:3 of @erd) 4 ?? ???? 8 ? (#xx:3 of @erd) bnot #xx:3, @aa:8 b (#xx:3 of @aa:8) 4 ? ????? 8 ? (#xx:3 of @aa:8) bnot rn, rd b (rn8 of rd8) 2 ? ????? 2 ? (rn8 of rd8) bnot rn, @erd b (rn8 of @erd) 4 ? ????? 8 ? (rn8 of @erd) bnot rn, @aa:8 b (rn8 of @aa:8) 4 ?????? 8 ? (rn8 of @aa:8) btst #xx:3, rd b ? (#xx:3 of rd8) z 2 ??? ? ? 2 btst #xx:3, @erd b ? (#xx:3 of @erd) z 4 ??? ? ? 6 btst #xx:3, @aa:8 b ? (#xx:3 of @aa:8) z 4 ??? ? ? 6 btst rn, rd b ? (rn8 of @rd8) z 2 ??? ? ? 2 btst rn, @erd b ? (rn8 of @erd) z 4 ??? ? ? 6 btst rn, @aa:8 b ? (rn8 of @aa:8) z 4 ??? ? ? 6 bld #xx:3, rd b (#xx:3 of rd8) c 2 ????? 2 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 572 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c bld #xx:3, @erd b (#xx:3 of @erd) c4 ????? 6 bld #xx:3, @aa:8 b (#xx:3 of @aa:8) c4 ????? 6 bild #xx:3, rd b ? (#xx:3 of rd8) c2 ????? 2 bild #xx:3, @erd b ? (#xx:3 of @erd) c4 ????? 6 bild #xx:3, @aa:8 b ? (#xx:3 of @aa:8) c4 ????? 6 bst #xx:3, rd b c (#xx:3 of rd8) 2 ?????? 2 bst #xx:3, @erd b c (#xx:3 of @erd24) 4 ?????? 8 bst #xx:3, @aa:8 b c (#xx:3 of @aa:8) 4 ?????? 8 bist #xx:3, rd b ? c (#xx:3 of rd8) 2 ?????? 2 bist #xx:3, @erd b ? c (#xx:3 of @erd24) 4 ?????? 8 bist #xx:3, @aa:8 b ? c (#xx:3 of @aa:8) 4 ?????? 8 band #xx:3, rd b c (#xx:3 of rd8) c2 ????? 2 band #xx:3, @erd b c (#xx:3 of @erd24) c 4 ????? 6 band #xx:3, @aa:8 b c (#xx:3 of @aa:8) c4 ????? 6 biand #xx:3, rd b c ? (#xx:3 of rd8) c2 ????? 2 biand #xx:3, @erd b c ? (#xx:3 of @erd24) c 4 ? ???? 6 biand #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) c 4 ? ???? 6 bor #xx:3, rd b c (#xx:3 of rd8) c2 ? ???? 2 bor #xx:3, @erd b c (#xx:3 of @erd24) c 4 ? ???? 6 bor #xx:3, @aa:8 b c (#xx:3 of @aa:8) c4 ????? 6 bior #xx:3, rd b c ? (#xx:3 of rd8) c2 ? ???? 2 bior #xx:3, @erd b c ? (#xx:3 of @erd24) c 4 ????? 6 bior #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) c 4 ????? 6 bxor #xx:3, rd bc (#xx:3 of rd8) c 2 ????? 2 bxor #xx:3, @erd b c (#xx:3 of @erd24) c 4 ????? 6 bxor #xx:3, @aa:8 bc (#xx:3 of @aa:8) c 4 ????? 6 bixor #xx:3, rd bc ? (#xx:3 of rd8) c 2 ????? 2 bixor #xx:3, @erd b c ? (#xx:3 of @erd24) c 4 ????? 6 bixor #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) c 4 ????? 6 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 573 of 682 rej09b0353-0300 6. branching instructions condition code mnemonic operation i h n z v c bra d:8 (bt d:8) ? always 2 ?????? 4 bra d:16 (bt d:16) ? 4 ?????? 6 brn d:8 (bf d:8) ? never 2 ?????? 4 brn d:16 (bf d:16) ? 4 ?????? 6 bhi d:8 ? c z = 0 2 ?????? 4 bhi d:16 ? 4 ?????? 6 bls d:8 ? c z = 1 2 ?????? 4 bls d:16 ? 4 ?????? 6 bcc d:8 (bhs d:8) ? c = 0 2 ?????? 4 bcc d:16 (bhs d:16) ? 4 ?????? 6 bcs d:8 (blo d:8) ? c = 1 2 ?????? 4 bcs d:16 (blo d:16) ? 4 ?????? 6 bne d:8 ? z = 0 2 ?????? 4 bne d:16 ? 4 ?????? 6 beq d:8 ? z = 1 2 ?????? 4 beq d:16 ? 4 ?????? 6 bvc d:8 ? v = 0 2 ?????? 4 bvc d:16 ? 4 ?????? 6 bvs d:8 ? v = 1 2 ?????? 4 bvs d:16 ? 4 ?????? 6 bpl d:8 ? n = 0 2 ?????? 4 bpl d:16 ? 4 ?????? 6 bmi d:8 ? n = 1 2 ?????? 4 bmi d:16 ? 4 ?????? 6 bge d:8 ? n v = 0 2 ?????? 4 bge d:16 ? 4 ?????? 6 bl t d:8 ? n v = 1 2 ?????? 4 bl t d:16 ? 4 ?????? 6 bgt d:8 ? 2 ?????? 4 bgt d:16 ? 4 ?????? 6 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size z (n v) = 0 if condition is true then pc pc+d else next;
appendix a instruction set rev.3.00 mar. 26, 2007 page 574 of 682 rej09b0353-0300 condition code mnemonic operation i h n z v c ble d:8 ? 2 ?????? 4 ble d:16 ? 4 ?????? 6 jmp @ern ? pc ern 2 ?????? 4 jmp @aa:24 ? pc aa:24 4 ?????? 6 jmp @@aa:8 ? pc @aa:8 2 ?????? 810 bsr d:8 ? pc @ ? sp 2 ?????? 68 pc pc+d:8 bsr d:16 ? pc @ ? sp 4 ?????? 810 pc pc+d:16 jsr @ern ? pc @ ? sp 2 ?????? 68 pc @ern jsr @aa:24 ? pc @ ? sp 4 ?????? 810 pc @aa:24 jsr @@aa:8 ? pc @ ? sp 2 ?????? 812 pc @aa:8 rts ? pc @sp+ 2 ? ????? 810 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size z (n v) = 1 if condition is true then pc pc+d else next;
appendix a instruction set rev.3.00 mar. 26, 2007 page 575 of 682 rej09b0353-0300 7. system control instructions condition code mnemonic operation i h n z v c trapa #x:2 ? pc @ ? sp 2 1 ????? 14 16 ccr @ ? sp pc rte ? ccr @sp+ 10 pc @sp+ sleep ? transition to power- ?????? 2 down state ldc #xx:8, ccr b #xx:8 ccr 2 2 ldc rs, ccr b rs8 ccr 2 2 ldc @ers, ccr w @ers ccr 4 6 ldc @(d:16, ers), w @(d:16, ers) ccr 6 8 ccr ldc @(d:24, ers), w @(d:24, ers) ccr 10 12 ccr ldc @ers+, ccr w @ers ccr 4 8 ers32+2 ers32 ldc @aa:16, ccr w @aa:16 ccr 6 8 ldc @aa:24, ccr w @aa:24 ccr 8 10 stc ccr, rd b ccr rd8 2 ? ????? 2 stc ccr, @erd w ccr @erd 4 ? ????? 6 stc ccr, @(d:16, w ccr @(d:16, erd) 6 ?????? 8 erd) stc ccr, @(d:24, w ccr @(d:24, erd) 10 ?????? 12 erd) stc ccr, @ ? erd w erd32 ? 2 erd32 4 ?????? 8 ccr @erd stc ccr, @aa:16 w ccr @aa:16 6 ?????? 8 stc ccr, @aa:24 w ccr @aa:24 8 ?????? 10 andc #xx:8, ccr b ccr #xx:8 ccr 2 2 orc #xx:8, ccr b ccr #xx:8 ccr 2 2 xorc #xx:8, ccr b ccr #xx:8 ccr 2 2 nop ? pc pc+2 2 ?????? 2 #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
appendix a instruction set rev.3.00 mar. 26, 2007 page 576 of 682 rej09b0353-0300 8. block transfer instructions condition code mnemonic operation i h n z v c eepmov. b ? if r4l 0 then 4 ?????? 8+4n * 2 repeat @r5 @r6 r5+1 r5 r6+1 r6 r4l ? 1 r4l until r4l=0 else next eepmov. w ? if r4 0 then 4 ?????? 8+4n * 2 repeat @r5 @r6 r5+1 r5 r6+1 r6 r4 ? 1 r4 until r4=0 else next #xx rn @ern @(d, ern) @ ? ern/@ern+ @aa @(d, pc) @@aa implied addressing mode and instruction length (bytes) normal no. of states * 1 advanced operand size notes: 1. the number of states is the number of states required for execution when the instruction and its operands are located in on-chip memory. for other cases see section a.3, number of states required for execution. 2. n is the value set in register r4l or r4. (1) set to 1 when a carry or borrow occurs at bit 11; otherwise cleared to 0. (2) set to 1 when a carry or borrow occurs at bit 27; otherwise cleared to 0. (3) retains its previous value when the result is zero; otherwise cleared to 0. (4) set to 1 when the adjustment produces a carry; otherwise retains its previous value. (5) the number of states required for execution of an instruction that transfers data in synchronization with the e clock is variable. (6) set to 1 when the divisor is negative; otherwise cleared to 0. (7) set to 1 when the divisor is zero; otherwise cleared to 0. (8) set to 1 when the quotient is negative; otherwise cleared to 0.
appendix a instruction set rev.3.00 mar. 26, 2007 page 577 of 682 rej09b0353-0300 a.2 operation code maps table a.2 operation code map (1) instruction code: ah al 0123456789abcdef 0 1 2 3 4 5 6 7 8 9 a b c d e f nop bra mulxu bset brn divxu bnot stc bhi mulxu bclr ldc bls divxu btst orc or.b bcc rts or xorc xor.b bcs bsr xor bor bior bxor bixor band biand andc and.b bne rte and ldc beq trapa bld bild bst bist bvc mov bpl jmp bmi eepmov addx subx bgt jsr ble mov mov.b add addx cmp subx or xor and mov instruction when most significant bit of bh is 0. instruction when most significant bit of bh is 1. table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) bvs blt bge bsr table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (2) table a.2 (3) 1st byte 2nd byte ah bh al bl add sub mov cmp
appendix a instruction set rev.3.00 mar. 26, 2007 page 578 of 682 rej09b0353-0300 table a.2 operation code map (2) ah al bh 0123456789abcdef 01 0a 0b 0f 10 11 12 13 17 1a 1b 1f 58 79 7a mov inc adds daa dec subs das bra mov mov bhi cmp cmp ldc/stc bcc or or bpl bgt instruction code: bvs sleep bvc bge table a.2 (3) table a.2 (3) table a.2 (3) add mov sub cmp bne and and inc extu dec beq inc extu dec bcs xor xor shll shlr rotxl rotxr not bls sub sub brn add add inc exts dec blt inc exts dec ble shal shar rotl rotr neg bmi 1st byte 2nd byte ah bh al bl sub adds shll shlr rotxl rotxr not shal shar rotl rotr neg
appendix a instruction set rev.3.00 mar. 26, 2007 page 579 of 682 rej09b0353-0300 table a.2 opera t ion code map (3) ah albh blch cl 0123456789abcdef 01406 01c05 01d05 01f06 7cr06 * 1 7cr07 * 1 7dr06 * 1 7dr07 * 1 7eaa6 * 2 7eaa7 * 2 7faa6 * 2 7faa7 * 2 mulxs bset bset bset bset divxs bnot bnot bnot bnot mulxs bclr bclr bclr bclr divxs btst btst btst btst or xor bor bior bxor bixor band biand and bld bild bst bist instruction when most significant bit of dh is 0. instruction when most significant bit of dh is 1. instruction code: bor bior bxor bixor band biand bld bild bst bist notes: 1. 2. r is the register designation field. aa is the absolute address field. 1st byte 2nd byte ah bh al bl 3rd byte ch dh cl dl 4th byte ldc stc ldc ldc ldc stc stc stc
appendix a instruction set rev.3.00 mar. 26, 2007 page 580 of 682 rej09b0353-0300 a.3 number of states required for execution the tables in this section can be used to calculate the number of states required for instruction execution by the h8/300h cpu. table a.3 indicates the number of states required per cycle according to the bus size. table a.4 indicates the number of instruction fetch, data read/write, and other cycles occurring in each instruction. the number of states required for execution of an instruction can be calculated from these two tables as follows: number of states = i s i + j s j + k s k + l s l + m s m + n s n examples of calculation of number of states required for execution examples: advanced mode, stack located in external address space, on-chip supporting modules accessed with 8-bit bus width, external devices accessed in three states with one wait state and 16-bit bus width. bset #0, @ffffc7:8 from table a.3, s i = 4 and s l = 3 from table a.4, i = l = 2 and j = k = m = n = 0 number of states = 2 4 + 2 3 = 14 jsr @@30 from table a.3, s i = s j = s k = 4 from table a.4, i = j = k = 2 and l = m = n = 0 number of states = 2 4 + 2 4 + 2 4 = 24
appendix a instruction set rev.3.00 mar. 26, 2007 page 581 of 682 rej09b0353-0300 table a.3 number of states per cycle access conditions external device on-chip supporting module 8-bit bus 16-bit bus cycle on-chip memory 8-bit bus 16-bit bus 2-state access 3-state access 2-state access 3-state access instruction fetch s i 2 6 3 4 6 + 2m 2 3 + m branch address read s j stack operation s k byte data access s l 323 + m word data access s m 6 4 6 + 2m internal operation s n 1111111 legend: m: number of wait states inserted in external device access
appendix a instruction set rev.3.00 mar. 26, 2007 page 582 of 682 rej09b0353-0300 table a.4 number of cycles per instruction instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n add add.b #xx:8, rd 1 add.b rs, rd 1 add.w #xx:16, rd 2 add.w rs, rd 1 add.l #xx:32, erd 3 add.l ers, erd 1 adds adds #1/2/4, erd 1 addx addx #xx:8, rd 1 addx rs, rd 1 and and.b #xx:8, rd 1 and.b rs, rd 1 and.w #xx:16, rd 2 and.w rs, rd 1 and.l #xx:32, erd 3 and.l ers, erd 2 andc andc #xx:8, ccr 1 band band #xx:3, rd 1 band #xx:3, @erd 2 1 band #xx:3, @aa:8 2 1 bcc bra d:8 (bt d:8) 2 brn d:8 (bf d:8) 2 bhi d:8 2 bls d:8 2 bcc d:8 (bhs d:8) 2 bcs d:8 (blo d:8) 2 bne d:8 2 beq d:8 2 bvc d:8 2 bvs d:8 2 bpl d:8 2 bmi d:8 2 bge d:8 2 blt d:8 2 bgt d:8 2 ble d:8 2
appendix a instruction set rev.3.00 mar. 26, 2007 page 583 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n bcc bra d:16 (bt d:16) 2 2 brn d:16 (bf d:16) 2 2 bhi d:16 2 2 bls d:16 2 2 bcc d:16 (bhs d:16) 2 2 bcs d:16 (blo d:16) 2 2 bne d:16 2 2 beq d:16 2 2 bvc d:16 2 2 bvs d:16 2 2 bpl d:16 2 2 bmi d:16 2 2 bge d:16 2 2 blt d:16 2 2 bgt d:16 2 2 ble d:16 2 2 bclr bclr #xx:3, rd 1 bclr #xx:3, @erd 2 2 bclr #xx:3, @aa:8 2 2 bclr rn, rd 1 bclr rn, @erd 2 2 bclr rn, @aa:8 2 2 biand biand #xx:3, rd 1 biand #xx:3, @erd 2 1 biand #xx:3, @aa:8 2 1 bild bild #xx:3, rd 1 bild #xx:3, @erd 2 1 bild #xx:3, @aa:8 2 1 bior bior #xx:8, rd 1 bior #xx:8, @erd 2 1 bior #xx:8, @aa:8 2 1 bist bist #xx:3, rd 1 bist #xx:3, @erd 2 2 bist #xx:3, @aa:8 2 2 bixor bixor #xx:3, rd 1 bixor #xx:3, @erd 2 1 bixor #xx:3, @aa:8 2 1
appendix a instruction set rev.3.00 mar. 26, 2007 page 584 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n bld bld #xx:3, rd 1 bld #xx:3, @erd 2 1 bld #xx:3, @aa:8 2 1 bnot bnot #xx:3, rd 1 bnot #xx:3, @erd 2 2 bnot #xx:3, @aa:8 2 2 bnot rn, rd 1 bnot rn, @erd 2 2 bnot rn, @aa:8 2 2 bor bor #xx:3, rd 1 bor #xx:3, @erd 2 1 bor #xx:3, @aa:8 2 1 bset bset #xx:3, rd 1 bset #xx:3, @erd 2 2 bset #xx:3, @aa:8 2 2 bset rn, rd 1 bset rn, @erd 2 2 bset rn, @aa:8 2 2 bsr bsr d:8 normal 2 1 advanced 2 2 bsr d:16 normal 2 1 2 advanced 2 2 2 bst bst #xx:3, rd 1 bst #xx:3, @erd 2 2 bst #xx:3, @aa:8 2 2 btst btst #xx:3, rd 1 btst #xx:3, @erd 2 1 btst #xx:3, @aa:8 2 1 btst rn, rd 1 btst rn, @erd 2 1 btst rn, @aa:8 2 1 bxor bxor #xx:3, rd 1 bxor #xx:3, @erd 2 1 bxor #xx:3, @aa:8 2 1
appendix a instruction set rev.3.00 mar. 26, 2007 page 585 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n cmp cmp.b #xx:8, rd 1 cmp.b rs, rd 1 cmp.w #xx:16, rd 2 cmp.w rs, rd 1 cmp.l #xx:32, erd 3 cmp.l ers, erd 1 daa daa rd 1 das das rd 1 dec dec.b rd 1 dec.w #1/2, rd 1 dec.l #1/2, erd 1 divxs divxs.b rs, rd 2 12 divxs.w rs, erd 2 20 divxu divxu.b rs, rd 1 12 divxu.w rs, erd 1 20 eepmov eepmov.b 2 2n +2 * 1 eepmov.w 2 2n +2 * 1 exts exts.w rd 1 exts.l erd 1 extu extu.w rd 1 extu.l erd 1 inc inc.b rd 1 inc.w #1/2, rd 1 inc.l #1/2, erd 1 jmp jmp @ern 2 jmp @aa:24 2 2 jmp @@aa:8 normal 2 1 2 advanced 2 2 2 jsr jsr @ern normal 2 1 advanced 2 2 jsr @aa:24 normal 2 1 2 advanced 2 2 2 jsr @@aa:8 normal 2 1 1 advanced 2 2 2
appendix a instruction set rev.3.00 mar. 26, 2007 page 586 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n ldc ldc #xx:8, ccr 1 ldc rs, ccr 1 ldc @ers, ccr 2 1 ldc @(d:16, ers), ccr 3 1 ldc @(d:24, ers), ccr 5 1 ldc @ers+, ccr 2 1 2 ldc @aa:16, ccr 3 1 ldc @aa:24, ccr 4 1 mov mov.b #xx:8, rd 1 mov.b rs, rd 1 mov.b @ers, rd 1 1 mov.b @(d:16, ers), rd 2 1 mov.b @(d:24, ers), rd 4 1 mov.b @ers+, rd 1 1 2 mov.b @aa:8, rd 1 1 mov.b @aa:16, rd 2 1 mov.b @aa:24, rd 3 1 mov.b rs, @erd 1 1 mov.b rs, @(d:16, erd) 2 1 mov.b rs, @(d:24, erd) 4 1 mov.b rs, @ ? erd 1 1 2 mov.b rs, @aa:8 1 1 mov.b rs, @aa:16 2 1 mov.b rs, @aa:24 3 1 mov.w #xx:16, rd 2 mov.w rs, rd 1 mov.w @ers, rd 1 1 mov.w @(d:16, ers), rd 2 1 mov.w @(d:24, ers), rd 4 1 mov.w @ers+, rd 1 1 2 mov.w @aa:16, rd 2 1 mov.w @aa:24, rd 3 1 mov.w rs, @erd 1 1 mov.w rs, @(d:16, erd) 2 1 mov.w rs, @(d:24, erd) 4 1 mov.w rs, @ ? erd 1 1 2 mov.w rs, @aa:16 2 1
appendix a instruction set rev.3.00 mar. 26, 2007 page 587 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n mov mov.w rs, @aa:24 3 1 mov.l #xx:32, erd 3 mov.l ers, erd 1 mov.l @ers, erd 2 2 mov.l @(d:16, ers), erd 3 2 mov.l @(d:24, ers), erd 5 2 mov.l @ers+, erd 2 2 2 mov.l @aa:16, erd 3 2 mov.l @aa:24, erd 4 2 mov.l ers, @erd 2 2 mov.l ers, @(d:16, erd) 3 2 mov.l ers, @(d:24, erd) 5 2 mov.l ers, @ ? erd 2 2 2 mov.l ers, @aa:16 3 2 mov.l ers, @aa:24 4 2 movfpe movfpe @aa:16, rd * 2 21 movtpe movtpe rs, @aa:16 * 2 21 mulxs mulxs.b rs, rd 2 12 mulxs.w rs, erd 2 20 mulxu mulxu.b rs, rd 1 12 mulxu.w rs, erd 1 20 neg neg.b rd 1 neg.w rd 1 neg.l erd 1 nop nop 1 not not.b rd 1 not.w rd 1 not.l erd 1 or or.b #xx:8, rd 1 or.b rs, rd 1 or.w #xx:16, rd 2 or.w rs, rd 1 or.l #xx:32, erd 3 or.l ers, erd 2
appendix a instruction set rev.3.00 mar. 26, 2007 page 588 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n orc orc #xx:8, ccr 1 pop pop.w rn 1 1 2 pop.l ern 2 2 2 push push.w rn 1 1 2 push.l ern 2 2 2 rotl rotl.b rd 1 rotl.w rd 1 rotl.l erd 1 rotr rotr.b rd 1 rotr.w rd 1 rotr.l erd 1 rotxl rotxl.b rd 1 rotxl.w rd 1 rotxl.l erd 1 rotxr rotxr.b rd 1 rotxr.w rd 1 rotxr.l erd 1 rte rte 2 2 2 rts rts normal 2 1 2 advanced 2 2 2 shal shal.b rd 1 shal.w rd 1 shal.l erd 1 shar shar.b rd 1 shar.w rd 1 shar.l erd 1 shll shll.b rd 1 shll.w rd 1 shll.l erd 1 shlr shlr.b rd 1 shlr.w rd 1 shlr.l erd 1 sleep sleep 1
appendix a instruction set rev.3.00 mar. 26, 2007 page 589 of 682 rej09b0353-0300 instruction mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n stc stc ccr, rd 1 stc ccr, @erd 2 1 stc ccr, @(d:16, erd) 3 1 stc ccr, @(d:24, erd) 5 1 stc ccr, @ ? erd 2 1 2 stc ccr, @aa:16 3 1 stc ccr, @aa:24 4 1 sub sub.b rs, rd 1 sub.w #xx:16, rd 2 sub.w rs, rd 1 sub.l #xx:32, erd 3 sub.l ers, erd 1 subs subs #1/2/4, erd 1 subx subx #xx:8, rd 1 subx rs, rd 1 trapa trapa #x:2 normal 2 1 2 4 advanced 2 2 2 4 xor xor.b #xx:8, rd 1 xor.b rs, rd 1 xor.w #xx:16, rd 2 xor.w rs, rd 1 xor.l #xx:32, erd 3 xor.l ers, erd 2 xorc xorc #xx:8, ccr 1 notes: 1. n is the value set in register r4l or r4. the source and destination are accessed n+1 times each. 2. not used with this lsi.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 590 of 682 rej09b0353-0300 appendix b internal i/o register field b.1 addresses bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'1c h'1d h'1e h'1f h'20? ???????? h'21? ???????? h'22? ???????? h'23? ???????? h'24? ???????? h'25? ???????? h'26? ???????? h'27? ???????? h'28? ???????? h'29? ???????? h'2a? ???????? h'2b? ???????? h'2c? ???????? h'2d? ???????? h'2e? ???????? h'2f? ???????? h'30? ???????? h'31? ???????? h'32? ???????? h'33? ???????? h'34? ???????? h'35? ???????? h'36? ???????? h'37? ???????? h'38? ???????? h'39? ???????? h'3a? ???????? h'3b? ???????? h'3c? ???????? h'3d? ???????? h'3e? ???????? h'3f? ????????
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 591 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'40 flmcr 8 fwe swe esu psu ev pv e p flash memory h'41? ???????? h'42 ebr 8 eb7 eb6 eb5 eb4 eb3 eb2 eb1 eb0 h'43? ???????? h'44? ???????? h'45? ???????? h'46? ???????? h'47 ramcr 8 ? ? ? ? rams ram2 ram1 ? h'48? ???????? h'49? ???????? h'4a? ???????? h'4b? ???????? h'4c? ???????? h'4dflmsr8fler??????? h'4e? ???????? h'4f? ???????? h'50? ???????? h'51? ???????? h'52? ???????? h'53? ???????? h'54? ???????? h'55? ???????? h'56? ???????? h'57? ???????? h'58? ???????? h'59? ???????? h'5a? ???????? h'5b? ???????? h'5c? ???????? h'5ddivcr8??????div1div0system control h'5e mstcr 8 pstop ? mstop5 mstop4 mstop3 ? ? mstop0 h'5f? ????????
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 592 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'60 tstr 8 ? ? ? str4 str3 str2 str1 str0 h'61 tsnc 8 ? ? ? sync4 sync3 sync2 sync1 sync0 itu (all channels) h'62 tmdr 8 mdf fdir pwm4 pwm3 pwm2 pwm1 pwm0 h'63 tfcr 8 ? ? cmd1 cmd0 bfb4 bfa4 bfb3 bfa3 h'64 tcr0 8 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 h'65 tior0 8 ? iob2 iob1 iob0 ? ioa2 ioa1 ioa0 itu channel 0 h'66 tier0 8 ? ? ? ? ? ovie imieb imiea h'67 tsr0 8 ? ? ? ? ? ovf imfb imfa h'68 tcnt0h 16 h'69 tcnt0l h'6a gra0h 16 h'6b gra0l h'6c grb0h 16 h'6d grb0l h'6e tcr1 8 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 h'6f tior1 8 ? iob2 iob1 iob0 ? ioa2 ioa1 ioa0 itu channel 1 h'70 tier1 8 ? ? ? ? ? ovie imieb imiea h'71 tsr1 8 ? ? ? ? ? ovf imfb imfa h'72 tcnt1h 16 h'73 tcnt1l h'74 gra1h 16 h'75 gra1l h'76 grb1h 16 h'77 grb1l h'78 tcr2 8 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 itu channel 2 h'79 tior2 8 ? iob2 iob1 iob0 ? ioa2 ioa1 ioa0 h'7a tier2 8 ? ? ? ? ? ovie imieb imiea h'7b tsr2 8 ? ? ? ? ? ovf imfb imfa h'7c tcnt2h 16 h'7d tcnt2l h'7e gra2h 16 h'7f gra2l h'80 grb2h 16 h'81 grb2l
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 593 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'82 tcr3 8 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 itu channel 3 h'83 tior3 8 ? iob2 iob1 iob0 ? ioa2 ioa1 ioa0 h'84 tier3 8 ? ? ? ? ? ovie imieb imiea h'85tsr38?????ovfimfbimfa h'86 tcnt3h 16 h'87 tcnt3l h'88 gra3h 16 h'89 gra3l h'8a grb3h 16 h'8b grb3l h'8c bra3h 16 h'8d bra3l h'8e brb3h 16 h'8f brb3l h'90 toer 8 ? ? exb4 exa4 eb3 eb4 ea4 ea3 h'91tocr8???xtgd??ols4ols3 itu (all channel) h'92 tcr4 8 ? cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 itu channel 4 h'93 tior4 8 ? iob2 iob1 iob0 ? ioa2 ioa1 ioa0 h'94 tier4 8 ? ? ? ? ? ovie imieb imiea h'95tsr48?????ovfimfbimfa h'96 tcnt4h 16 h'97 tcnt4l h'98 gra4h 16 h'99 gra4l h'9a grb4h 16 h'9b grb4l h'9c bra4h 16 h'9d bra4l h'9e brb4h 16 h'9f brb4l
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 594 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'a0 tpmr 8 ? ? ? ? g3nov g2nov g1nov g0nov tpc h'a1 tpcr 8 g3cms1 g3cms0 g2cms1 g2cms0 g1cms1 g1cms0 g0cms1 g0cms0 h'a2 nderb 8 nder15 nder14 nder13 nder12 nder11 nder10 nder9 nder8 h'a3 ndera 8 nder7 nder6 nder5 nder4 nder3 nder2 nder1 nder0 h'a4 ndrb * 1 8 ndr15 ndr14 ndr13 ndr12 ndr11 ndr10 ndr9 ndr8 8 ndr15 ndr14 ndr13 ndr12 ? ? ? ? h'a5 ndra * 1 8 ndr7 ndr6 ndr5 ndr4 ndr3 ndr2 ndr1 ndr0 8 ndr7 ndr6 ndr5 ndr4 ? ? ? ? h'a6 ndrb * 1 8???????? 8 ? ? ? ? ndr11 ndr10 ndr9 ndr8 h'a7 ndra * 1 8???????? 8 ? ? ? ? ndr3 ndr2 ndr1 ndr0 h'a8 tcsr * 2 8ovfwt/ it tme ? ? cks2 cks1 cks0 wdt h'a9 tcnt * 2 8 h'aa? ???????? h'ab rstcsr * 2 8wrstrstoe?????? h'ac? ???????? h'ad? ???????? h'ae? ???????? h'af? ???????? h'b0 smr 8 c/ a chr pe o/ e stop mp cks1 cks0 sci0 h'b1 brr 8 h'b2 scr 8 tie rie te re mpie teie cke1 cke0 h'b3 tdr 8 h'b4 ssr 8 tdre rdrf orer fer per tend mpb mpbt h'b5 rdr 8 h'b6 scmr 8 ? ? ? ? sdir sinv ? smif smart card interface h'b7 h'b8 smr 8 c/ a chr pe o/ e stop mp cks1 cks0 sci1 h'b9brr8???????? h'ba scr 8 tie rie te re mpie teie cke1 cke0 h'bbtdr8???????? h'bc ssr 8 tdre rdrf orer fer per tend mpb mpbt h'bdrdr8???????? h'be? ???????? h'bf? ????????
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 595 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'c0 p1ddr 8 p1 7 ddr p1 6 ddr p1 5 ddr p1 4 ddr p1 3 ddr p1 2 ddr p1 1 ddr p1 0 ddr port 1 h'c1 p2ddr 8 p2 7 ddr p2 6 ddr p2 5 ddr p2 4 ddr p2 3 ddr p2 2 ddr p2 1 ddr p2 0 ddr port 2 h'c2 p1dr 8 p1 7 p1 6 p1 5 p1 4 p1 3 p1 2 p1 1 p1 0 port 1 h'c3 p2dr 8 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 port 2 h'c4 p3ddr 8 p3 7 ddr p3 6 ddr p3 5 ddr p3 4 ddr p3 3 ddr p3 2 ddr p3 1 ddr p3 0 ddr port 3 h'c5? ???????? h'c6 p3dr 8 p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 port 3 h'c7? ???????? h'c8 p5ddr 8 ? ? ? ? p5 3 ddr p5 2 ddr p5 1 ddr p5 0 ddr port 5 h'c9 p6ddr 8 ? ? p6 5 ddr p6 4 ddr p6 3 ddr ? ? p6 0 ddr port 6 h'ca p5dr 8 ? ? ? ? p5 3 p5 2 p5 1 p5 0 port 5 h'cb p6dr 8 ? ? p6 5 p6 4 p6 3 ??p6 0 port 6 h'cc? ???????? h'cd p8ddr 8 ? ? ? ? ? ? p8 1 ddr p8 0 ddr port 8 h'ce p7dr 8 p7 7 p7 6 p7 5 p7 4 p7 3 p7 2 p7 1 p7 0 port 7 h'cf p8dr 8 ? ? ? ? ? ? p8 1 p8 0 port 8 h'd0 p9ddr 8 ? ? p9 5 ddr p9 4 ddr p9 3 ddr p9 2 ddr p9 1 ddr p9 0 ddr port 9 h'd1 paddr 8 pa 7 ddr pa 6 ddr pa 5 ddr pa 4 ddr pa 3 ddr pa 2 ddr pa 1 ddr pa 0 ddr port a h'd2 p9dr 8 ? ? p9 5 p9 4 p9 3 p9 2 p9 1 p9 0 port 9 h'd3 padr 8 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 port a h'd4 pbddr 8 pb 7 ddr ? pb 5 ddr pb 4 ddr pb 3 ddr pb 2 ddr pb 1 ddr pb 0 ddr port b h'd5? ???????? h'd6 pbdr 8 pb 7 ?pb 5 pb 4 pb 3 pb 2 pb 1 pb 0 port b h'd7? ???????? h'd8 p2pcr 8 p2 7 pcr p2 6 pcr p2 5 pcr p2 4 pcr p2 3 pcr p2 2 pcr p2 1 pcr p2 0 pcr port 2 h'd9? ???????? h'da? ???????? h'db p5pcr 8 ? ? ? ? p5 3 pcr p5 2 pcr p5 1 pcr p5 0 pcr port 5 h'dc? ???????? h'dd? ???????? h'de? ???????? h'df? ????????
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 596 of 682 rej09b0353-0300 bit names address (low) register name data bus width bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module name h'e0 addrah 8 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 a/d h'e1 addral 8 ad1 ad0 ? ? ? ? ? ? h'e2 addrbh 8 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'e3 addrbl 8 ad1 ad0 ? ? ? ? ? ? h'e4 addrch 8 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'e5 addrcl 8 ad1 ad0 ? ? ? ? ? ? h'e6 addrdh 8 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 h'e7 addrdl 8 ad1 ad0 ? ? ? ? ? ? h'e8 adcsr 8 adf adie adst scan cks ch2 ch1 ch0 h'e9 adcr 8 trge ? ? ? ? ? ? ? h'ea? ???????? h'eb? ???????? h'ec? ????????bus controller h'ed astcr 8 ast7 ast6 ast5 ast4 ast3 ast2 ast1 ast0 h'ee wcr 8 ? ? ? ? wms1 wms0 wc1 wc0 h'ef wcer 8 wce7 wce6 wce5 wce4 wce3 wce2 wce1 wce0 h'f0? ???????? h'f1 mdcr 8 ? ? ? ? ? mds2 mds1 mds0 system control h'f2 syscr 8 ssby sts2 sts1 sts0 ue nmieg ? rame h'f3 adrcr 8 a 23 ea 22 ea 21 e?????bus controller h'f4 iscr 8 ? ? irq5sc irq4sc ? ? irq1sc irq0sc interrupt controller h'f5 ier 8 ? ? irq5e irq4e ? ? irq1e irq0e h'f6 isr 8 ? ? irq5f irq4f ? ? irq1f irq0f h'f7? ???????? h'f8 ipra 8 ipra7 ipra6 ? ipra4 ipra3 ipra2 ipra1 ipra0 h'f9 iprb 8 iprb7 iprb6 ? ? iprb3 iprb2 iprb1 ? h'fa? ???????? h'fb? ???????? h'fc h'fd? ???????? h'fe? ???????? h'ff? ???????? legend: itu: 16-bit integrated timer unit tpc: programmable timing pattern controller wdt: watchdog timer sci: serial communication interface a/d: a/d converter notes: 1. the address depends on the output trigger setting. 2. for write access to tcsr, tcnt, and rstcsr, see section 10.2.4, notes on register access.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 597 of 682 rej09b0353-0300 b.2 function tstr timer start register h'60 itu (all channels) register name address to which the register is mapped name of on-chip supporting module register acronym bit numbers initial bit values names of the bits. dashes ( ? ) indicate reserved bits. full name of bit descriptions of bit settings read only write only read and write r w r/w possible types of access bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 str4 0 r/w 3 str3 0 r/w 0 str0 0 r/w 2 str2 0 r/w 1 str1 0 r/w counter start 0 0 tcnt0 is halted 1 tcnt0 is counting counter start 3 0 tcnt3 is halted 1 tcnt3 is counting counter start 1 0 tcnt1 is halted 1 tcnt1 is counting counter start 2 0 tcnt2 is halted 1 tcnt2 is counting counter start 4 0 tcnt4 is halted 1 tcnt4 is counting
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 598 of 682 rej09b0353-0300 flmcr?flash memory control register h'40 flash memory bit initial value read/write 1/0 r 7 fwe 0 r/w 6 swe 0 r/w 5 esu 0 r/w 4 psu 0 r/w 3 ev 0 r/w 2 pv 0 r/w 1 e 0 r/w initial value read/write modes 5 and 7 modes 1 to 4, and 6 0 r 0 r 0 r 0 r 0 r 0 r 0 r 0 r 0 p 0 1 program mode cleared (initial value) transition to program mode [setting condition] when fwe = 1, swe = 1, and psu = 1 program mode 0 1 erase mode cleared (initial value) transition to erase mode [setting condition] when fwe = 1, swe = 1, and esu = 1 erase mode 0 1 program-verify mode cleared (initial value) transition to program-verify mode [setting condition] when fwe = 1 and swe = 1 program-verify mode 0 1 erase-verify mode cleared (initial value) transition to erase-verify mode [setting condition] when fwe = 1 and swe = 1 erase-verify mode 0 1 program setup cleared (initial value) program setup [setting condition] when fwe = 1 and swe = 1 program setup 0 1 erase setup cleared (initial value) erase setup [setting condition] when fwe = 1 and swe = 1 erase setup 0 1 program/erase disabled (initial value) program/erase enabled [setting condition] when fwe = 1 software write enable bit 0 1 when a low level is input to the fwe pin (hardware protection state) when a high level is input to the fwe pin flash write enable bit note: this register is used only in the flash memory versions. reading the corresponding address in a mask rom version will always return 1s, and writes to this address are disabled. fix the fwe pin low in mode 6.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 599 of 682 rej09b0353-0300 ebr?erase block register h'42 flash memory bit 7 eb7 6 eb6 5 eb5 4 eb4 3 eb3 2 eb2 1 eb1 0 eb0 0 1 block eb7 to eb0 is not selected (initial value) block eb7 to eb0 is selected block 7 to 0 note: when not erasing flash memory, ebr should be cleared to h'00. this register is used only in the flash memory versions. reading the corresponding address in a mask rom version will always return 1s, and writes to this address are disabled. 1s cannot be set in this register in mode 6. initial value read/write 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w 0 r/w initial value read/write modes 5 to 7 modes 1 to 4, and 6 0 r 0 r 0 r 0 r 0 r 0 r 0 r 0 r
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 600 of 682 rej09b0353-0300 ramcr?ram control register h'47 flash memory bit 3 bit 2 bit 1 rams ram2 ram1 ram area 0 1 0/1 0 1 0/1 0 1 0 1 ram emulation status h'fff000 to h'fff3ff h'000000 to h'0003ff h'000400 to h'0007ff h'000800 to h'000bff h'000c00 to h'000fff no emulation mapping ram ram select, ram2, ram1 note: bit 7 ? rams 6543210 ??? ram2 ram1 ? reserved bits modes 1 to 4 1 ? 1 ? 1 ? 1 ? 0 r 0 r 0 r 1 ? initial value read/write initial value read/write modes 5 to 7 1 ? 1 ? 1 ? 1 ? 0 r/w * 0 r/w * 0 r/w * 1 ? this register is used only in the flash memory versions. reading the corresponding address in a mask rom version will always return 1s, and writes to this address are disabled. * in mode 6 (single-chip normal mode), flash memory emulation by ram is not supported; these bits can be modified, but must not be set to 1.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 601 of 682 rej09b0353-0300 flmsr?flash memory status register h'4d flash memory bit 76543210 fler ?? ?? ? ? initial value 0 1 1 1 1 1 1 1 read/write r ?? ?? ? ?? ? flash memory error 0 1 flash memory write/erase protection is disabled (initial value) an error has occurred during flash memory writing/erasing flash memory error protection is enabled divcr?division control register h'5d system control bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 3 ? 1 ? 0 div0 0 r/w 2 ? 1 ? 1 div1 0 r/w divide bits 1 and 0 div1 frequency division ratio div0 bit 0 bit 1 0 1 1/1initial value 1/2 1/4 1/8 0 0 1 1 7 ? 1 ?
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 602 of 682 rej09b0353-0300 mstcr?module standby control register h'5e system control bit initial value read/write 7 pstop 0 r/w 6 ? 1 ? 5 mstop5 0 r/w 4 mstop4 0 r/w 3 mstop3 0 r/w 0 mstop0 0 r/w 2 ? 0 r/w 1 ? 0 r/w module standby 0 0 a/d converter operates normally 1 a/d converter is in standby state module standby 3 0 sci1 operates normally 1 sci1 is in standby state module standby 4 0 sci0 operates normally 1 sci0 is in standby state module standby 5 0 itu operates normally 1 itu is in standby state clock stop 0 clock output is enabled 1 clock output is disabled
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 603 of 682 rej09b0353-0300 tstr?timer start register h'60 itu (all channels) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 str4 0 r/w 3 str3 0 r/w 0 str0 0 r/w 2 str2 0 r/w 1 str1 0 r/w counter start 0 0 tcnt0 is halted 1 tcnt0 is counting counter start 3 0 tcnt3 is halted 1 tcnt3 is counting counter start 1 0 tcnt1 is halted 1 tcnt1 is counting counter start 2 0 tcnt2 is halted 1 tcnt2 is counting counter start 4 0 tcnt4 is halted 1 tcnt4 is counting
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 604 of 682 rej09b0353-0300 tsnc?timer synchro register h'61 itu (all channels) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 sync4 0 r/w 3 sync3 0 r/w 0 sync0 0 r/w 2 sync2 0 r/w 1 sync1 0 r/w timer sync 0 0 tcnt0 operates independently 1 tcnt0 is synchronized timer sync 3 0 tcnt3 operates independently 1 tcnt3 is synchronized timer sync 1 0 tcnt1 operates independently 1 tcnt1 is synchronized timer sync 2 0 tcnt2 operates independently 1 tcnt2 is synchronized timer sync 4 0 tcnt4 operates independently 1 tcnt4 is synchronized
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 605 of 682 rej09b0353-0300 tmdr?timer mode register h'62 itu (all channels) bit initial value read/write 7 ? 1 ? 6 mdf 0 r/w 5 fdir 0 r/w 4 pwm4 0 r/w 3 pwm3 0 r/w 0 pwm0 0 r/w 2 pwm2 0 r/w 1 pwm1 0 r/w pwm mode 0 0 channel 0 operates normally 1 channel 0 operates in pwm mode pwm mode 3 0 channel 3 operates normally 1 channel 3 operates in pwm mode pwm mode 1 0 channel 1 operates normally 1 channel 1 operates in pwm mode pwm mode 2 0 channel 2 operates normally 1 channel 2 operates in pwm mode pwm mode 4 0 channel 4 operates normally 1 channel 4 operates in pwm mode flag direction 0 ovf is set to 1 in tsr2 when tcnt2 overflows or underflows 1 ovf is set to 1 in tsr2 when tcnt2 overflows phase counting mode flag 0 channel 2 operates normally 1 channel 2 operates in phase counting mode
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 606 of 682 rej09b0353-0300 tfcr?timer function control register h'63 itu (all channels) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 cmd1 0 r/w 4 cmd0 0 r/w 3 bfb4 0 r/w 0 bfa3 0 r/w 2 bfa4 0 r/w 1 bfb3 0 r/w buffer mode a3 0 gra3 operates normally 1 gra3 is buffered by bra3 buffer mode b4 0 grb4 operates normally 1 grb4 is buffered by brb4 buffer mode b3 0 grb3 operates normally 1 grb3 is buffered by brb3 buffer mode a4 0 gra4 operates normally 1 gra4 is buffered by bra4 combination mode 1 and 0 channels 3 and 4 operate normally channels 3 and 4 operate together in complementary pwm mode channels 3 and 4 operate together in reset-synchronized pwm mode bit 5 0 1 bit 4 0 1 0 1 operating mode of channels 3 and 4 cmd1 cmd0
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 607 of 682 rej09b0353-0300 tcr0?timer control register 0 h'64 itu0 bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 ckeg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w timer prescaler 2 to 0 clock edge 1 and 0 counter clear 1 and 0 tcnt is not cleared tcnt is cleared by grb compare match or input capture synchronous clear: bit 6 0 1 bit 5 0 0 1 tcnt clear source cclr1 cclr0 tcnt is cleared by gra compare match or input capture 1 rising edges counted both edges counted bit 4 0 1 bit 3 0 ? counted edges of external clock ckeg1 ckeg0 falling edges counted 1 tpsc2 1 tcnt clock source internal clock: internal clock: /2 internal clock: /4 internal clock: /8 external clock a: tclka input external clock b: tclkb input external clock c: tclkc input bit 2 tpsc1 0 1 0 1 bit 1 tpsc0 0 1 0 1 0 1 bit 0 0 external clock d: tclkd input 1 0 tcnt is cleared in synchronization with other synchronized timers
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 608 of 682 rej09b0353-0300 tior0?timer i/o control register 0 h'65 itu0 bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w i/o control a2 to a0 ioa2 1 gra function gra is an output compare register gra is an input capture register ioa1 0 1 0 1 bit 1 ioa0 0 1 0 1 0 1 bit 0 0 1 0 bit 2 no output at compare match 0 output at gra compare match 1 output at gra compare match output toggles at gra compare match gra captures rising edge of input gra captures falling edge of input gra captures both edges of input i/o control b2 to b0 iob2 1 grb function grb is an output compare register grb is an input capture register iob1 0 1 0 1 bit 5 iob0 0 1 0 1 0 1 bit 4 0 1 0 bit 6 no output at compare match 0 output at grb compare match 1 output at grb compare match output toggles at grb compare match grb captures rising edge of input grb captures falling edge of input grb captures both edges of input
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 609 of 682 rej09b0353-0300 tier0?timer interrupt enable register 0 h'66 itu0 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imiea 0 r/w 2 ovie 0 r/w 1 imieb 0 r/w input capture/compare match interrupt enable a 0 imia interrupt requested by imfa is disabled 1 imia interrupt requested by imfa is enabled input capture/compare match interrupt enable b 0 imib interrupt requested by imfb is disabled 1 imib interrupt requested by imfb is enabled overflow interrupt enable 0 ovi interrupt requested by ovf is disabled 1 ovi interrupt requested by ovf is enabled
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 610 of 682 rej09b0353-0300 tsr0?timer status register 0 h'67 itu0 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imfa 0 r/(w) 2 ovf 0 r/(w) 1 imfb 0 r/(w) input capture/compare match flag a 0 [clearing condition] overflow flag *** read imfa when imfa = 1, then write 0 in imfa 1 [setting conditions]  tcnt = gra when gra functions as a compare match register.  tcnt value is transferred to gra by an input capture signal, when gra functions as an input capture register. input capture/compare match flag b 0 [clearing condition] read imfb when imfb = 1, then write 0 in imfb 1 [setting conditions]  tcnt = grb when grb functions as a compare match register.  tcnt value is transferred to grb by an input capture signal, when grb functions as an input capture register. 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] tcnt overflowed from h'ffff to h'0000 note: * only 0 can be written to clear the flag.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 611 of 682 rej09b0353-0300 tcnt0 h/l?timer counter 0 h/l h'68, h'69 itu0 bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w up-counter 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w gra0 h/l?general register a0 h/l h'6a, h'6b itu0 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w output compare or input capture register 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w grb0 h/l?general register b0 h/l h'6c, h'6d itu0 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w output compare or input capture register 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w tcr1?timer control register 1 h'6e itu1 bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 ckeg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w note: bit functions are the same as for itu0.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 612 of 682 rej09b0353-0300 tior1?timer i/o control register 1 h'6f itu1 bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w note: bit functions are the same as for itu0. tier1?timer interrupt enable register 1 h'70 itu1 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imiea 0 r/w 2 ovie 0 r/w 1 imieb 0 r/w note: bit functions are the same as for itu0. tsr1?timer status register 1 h'71 itu1 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imfa 0 r/(w) 2 ovf 0 r/(w) 1 imfb 0 r/(w) notes: *** bit functions are the same as for itu0. * only 0 can be written to clear the flag. tcnt1 h/l?timer counter 1 h/l h'72, h'73 itu1 bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w note: bit functions are the same as for itu0.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 613 of 682 rej09b0353-0300 gra1 h/l?general register a1 h/l h'74, h'75 itu1 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu0. grb1 h/l?general register b1 h/l h'76, h'77 itu1 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu0. tcr2?timer control register 2 h'78 itu2 bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 ckeg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w notes: 1. bit functions are the same as for itu0. 2. when channel 2 is used in phase counting mode, the counter clock source selection by bits ckeg1, ckeg0 and tpsc2 to tpsc0 is ignored.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 614 of 682 rej09b0353-0300 tior2?timer i/o control register 2 h'79 itu2 bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w notes: 1. bit functions are the same as for itu0. 2. channel 2 does not have a compare match toggle output function. if this setting is used, 1 output will be selected automatically. tier2?timer interrupt enable register 2 h'7a itu2 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imiea 0 r/w 2 ovie 0 r/w 1 imieb 0 r/w note: bit functions are the same as for itu0.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 615 of 682 rej09b0353-0300 tsr2?timer status register 2 h'7b itu2 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imfa 0 r/(w) 2 ovf 0 r/(w) 1 imfb 0 r/(w) overflow flag 0 [clearing condition] *** read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] tcnt overflowed from h'ffff to h'0000 or underflowed from h'0000 to h'ffff bit functions are the same as for itu0 note: * only 0 can be written to clear the flag. tcnt2 h/l?timer counter 2 h/l h'7c, h'7d itu2 bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w phase counting mode: other modes: up-counter 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w up/down-counter
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 616 of 682 rej09b0353-0300 gra2 h/l?general register a2 h/l h'7e, h'7f itu2 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu0. grb2 h/l?general register b2 h/l h'80, h'81 itu2 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu0. tcr3?timer control register 3 h'82 itu3 bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 cleg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w note: bit functions are the same as for itu0. tior3?timer i/o control register 3 h'83 itu3 bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w note: bit functions are the same as for itu0.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 617 of 682 rej09b0353-0300 tier3?timer interrupt enable register 3 h'84 itu3 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imiea 0 r/w 2 ovie 0 r/w 1 imieb 0 r/w note: bit functions are the same as for itu0. tsr3?timer status register 3 h'85 itu3 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imfa 0 r/(w) 2 ovf 0 r/(w) 1 imfb 0 r/(w) *** overflow flag 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] tcnt overflowed from h'ffff to h'0000 or underflowed from h'0000 to h'ffff bit functions are the same as for itu0 note: * only 0 can be written to clear the flag. tcnt3 h/l?timer counter 3 h/l h'86, h'87 itu3 bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w complementary pwm mode: other modes: up-counter 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w up/down counter
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 618 of 682 rej09b0353-0300 gra3 h/l?general register a3 h/l h'88, h'89 itu3 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w output compare or input capture register (can be buffered) 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w grb3 h/l?general register b3 h/l h'8a, h'8b itu3 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w output compare or input capture register (can be buffered) 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w bra3 h/l?buffer register a3 h/l h'8c, h'8d itu3 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w used to buffer gra 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w brb3 h/l?buffer register b3 h/l h'8e, h'8f itu3 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w used to buffer grb 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 619 of 682 rej09b0353-0300 toer?timer output enable register h'90 itu (all channels) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 exb4 1 r/w 4 exa4 1 r/w 3 eb3 1 r/w 0 ea3 1 r/w 2 eb4 1 r/w 1 ea4 1 r/w master enable tioca 3 0 tioca output is disabled regardless of tior3, tmdr, and tfcr settings 1 tioca is enabled for output according to tior3, tmdr, and tfcr settings master enable tiocb 3 0 tiocb output is disabled regardless of tior3 and tfcr settings 1 tiocb is enabled for output according to tior3 and tfcr settings master enable tioca 4 0 tioca output is disabled regardless of tior4, tmdr, and tfcr settings 1 tioca is enabled for output according to tior4, tmdr, and tfcr settings master enable tiocb 4 0 tiocb output is disabled regardless of tior4 and tfcr settings 1 tiocb is enabled for output according to tior4 and tfcr settings master enable tocxa 4 0 tocxa output is disabled regardless of tfcr settings 1 tocxa is enabled for output according to tfcr settings master enable tocxb 4 0 tocxb output is disabled regardless of tfcr settings 1 tocxb is enabled for output according to tfcr settings 4 4 4 4 3 3 4 4 4 4 3 3
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 620 of 682 rej09b0353-0300 tocr?timer output control register h'91 itu (all channels) bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 1 r/w 3 ? 1 ? 0 ols3 1 r/w 2 ? 1 ? 1 ols4 1 r/w output level select 3 0 tiocb , tocxa , and tocxb outputs are inverted 1 tiocb , tocxa , and tocxb outputs are not inverted output level select 4 0 tioca , tioca , and tiocb outputs are inverted 1 tioca , tioca , and tiocb outputs are not inverted external trigger disable 0 input capture a in channel 1 is used as an external trigger signal in reset-synchronized pwm mode and complementary pwm mode * 1 external triggering is disabled xtgd note: * when an external trigger occurs, bits 5 to 0 in toer are cleared to 0, disabling itu output. 3 3 3 3 4 4 4 4 4 4 4 4 tcr4?timer control register 4 h'92 itu4 bit initial value read/write 7 ? 1 ? 6 cclr1 0 r/w 5 cclr0 0 r/w 4 ckeg1 0 r/w 3 ckeg0 0 r/w 0 tpsc0 0 r/w 2 tpsc2 0 r/w 1 tpsc1 0 r/w note: bit functions are the same as for itu0.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 621 of 682 rej09b0353-0300 tior4?timer i/o control register 4 h'93 itu4 bit initial value read/write 7 ? 1 ? 6 iob2 0 r/w 5 iob1 0 r/w 4 iob0 0 r/w 3 ? 1 ? 0 ioa0 0 r/w 2 ioa2 0 r/w 1 ioa1 0 r/w note: bit functions are the same as for itu0. tier4?timer interrupt enable register 4 h'94 itu4 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imiea 0 r/w 2 ovie 0 r/w 1 imieb 0 r/w note: bit functions are the same as for itu0. tsr4?timer status register 4 h'95 itu4 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 imfa 0 r/(w) 2 ovf 0 r/(w) 1 imfb 0 r/(w) *** notes: bit functions are the same as for itu0. * only 0 can be written to clear the flag. tcnt4 h/l?timer counter 4 h/l h'96, h'97 itu4 bit initial value read/write 14 0 r/w 12 0 r/w 10 0 r/w 8 0 r/w 6 0 r/w 0 0 r/w 4 0 r/w 2 0 r/w 15 0 r/w 13 0 r/w 11 0 r/w 9 0 r/w 7 0 r/w 1 0 r/w 5 0 r/w 3 0 r/w note: bit functions are the same as for itu3.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 622 of 682 rej09b0353-0300 gra4 h/l?general register a4 h/l h'98, h'99 itu4 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu3. grb4 h/l?general register b4 h/l h'9a, h'9b itu4 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu3. bra4 h/l?buffer register a4 h/l h'9c, h'9d itu4 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu3. brb4 h/l?buffer register b4 h/l h'9e, h'9f itu4 bit initial value read/write 14 1 r/w 12 1 r/w 10 1 r/w 8 1 r/w 6 1 r/w 0 1 r/w 4 1 r/w 2 1 r/w 15 1 r/w 13 1 r/w 11 1 r/w 9 1 r/w 7 1 r/w 1 1 r/w 5 1 r/w 3 1 r/w note: bit functions are the same as for itu3.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 623 of 682 rej09b0353-0300 tpmr?tpc output mode register h'a0 tpc bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 g3nov 0 r/w 0 g0nov 0 r/w 2 g2nov 0 r/w 1 g1nov 0 r/w group 3 non-overlap 0 normal tpc output in group 3 output values change at compare match a in the selected itu channel 1 non-overlapping tpc output in group 3, controlled by compare match a and b in the selected itu channel group 2 non-overlap 0 normal tpc output in group 2 output values change at compare match a in the selected itu channel 1 non-overlapping tpc output in group 2, controlled by compare match a and b in the selected itu channel group 1 non-overlap 0 normal tpc output in group 1 output values change at compare match a in the selected itu channel 1 non-overlapping tpc output in group 1, controlled by compare match a and b in the selected itu channel group 0 non-overlap 0 normal tpc output in group 0 output values change at compare match a in the selected itu channel 1 non-overlapping tpc output in group 0, controlled by compare match a and b in the selected itu channel
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 624 of 682 rej09b0353-0300 tpcr?tpc output control register h'a1 tpc bit initial value read/write 7 g3cms1 1 r/w 6 g3cms0 1 r/w 5 g2cms1 1 r/w 4 g2cms0 1 r/w 3 g1cms1 1 r/w 0 g0cms0 1 r/w 2 g1cms0 1 r/w 1 g0cms1 1 r/w group 3 compare match select 1 and 0 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 0 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 2 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 3 bit 7 0 1 bit 6 0 0 1 itu channel selected as output trigger g3cms1 g3cms0 tpc output group 3 (tp 15 to tp 12 ) * is triggered by compare match in itu channel 1 1 group 2 compare match select 1 and 0 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 0 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 2 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 3 bit 5 0 1 bit 4 0 0 1 itu channel selected as output trigger g2cms1 g2cms0 tpc output group 2 (tp 11 to tp 8 ) is triggered by compare match in itu channel 1 1 group 1 compare match select 1 and 0 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 0 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 2 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 3 bit 3 0 1 bit 2 0 0 1 itu channel selected as output trigger g1cms1 g1cms0 tpc output group 1 (tp 7 to tp 4 ) is triggered by compare match in itu channel 1 1 group 0 compare match select 1 and 0 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 0 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 2 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 3 bit 1 0 1 bit 0 0 0 1 itu channel selected as output trigger g0cms1 g0cms0 tpc output group 0 (tp 3 to tp 0 ) is triggered by compare match in itu channel 1 1 note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 625 of 682 rej09b0353-0300 nderb?next data enable register b h'a2 tpc bit initial value read/write 7 nder15 0 r/w 6 nder14 0 r/w 5 nder13 0 r/w 4 nder12 0 r/w 3 nder11 0 r/w 0 nder8 0 r/w 2 nder10 0 r/w 1 nder9 0 r/w next data enable 15 to 8 tpc outputs tp to tp * are disabled (ndr15 to ndr8 are not transferred to pb to pb ) tpc outputs tp to tp * are enabled (ndr15 to ndr8 are transferred to pb to pb ) bits 7 to 0 0 1 description note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip. nder15 to nder8 15 15 8 8 7 7 0 0 ndera?next data enable register a h'a3 tpc bit initial value read/write 7 nder7 0 r/w 6 nder6 0 r/w 5 nder5 0 r/w 4 nder4 0 r/w 3 nder3 0 r/w 0 nder0 0 r/w 2 nder2 0 r/w 1 nder1 0 r/w next data enable 7 to 0 tpc outputs tp to tp are disabled (ndr7 to ndr0 are not transferred to pa to pa ) tpc outputs tp to tp are enabled (ndr7 to ndr0 are transferred to pa to pa ) bits 7 to 0 0 1 description nder7 to nder0 7 7 0 0 7 7 0 0
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 626 of 682 rej09b0353-0300 ndrb?next data register b h'a4/h'a6 tpc ? same output trigger for tpc output groups 2 and 3 address h'ffa4 bit initial value read/write 7 ndr15 0 r/w 6 ndr14 0 r/w 5 ndr13 0 r/w 4 ndr12 0 r/w 3 ndr11 0 r/w 0 ndr8 0 r/w 2 ndr10 0 r/w 1 ndr9 0 r/w next output data for tpc output group 3 * next output data for tpc output group 2 address h'ffa6 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? ? different output triggers for tpc output groups 2 and 3 address h'ffa4 bit initial value read/write 7 ndr15 0 r/w 6 ndr14 0 r/w 5 ndr13 0 r/w 4 ndr12 0 r/w 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? next output data for tpc output group 3 * address h'ffa6 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ndr11 0 r/w 0 ndr8 0 r/w 2 ndr10 0 r/w 1 ndr9 0 r/w next output data for tpc output group 2 note: * since this lsi does not have a tp 14 pin, the tp 14 signal cannot be output off-chip.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 627 of 682 rej09b0353-0300 ndra?next data register a h'a5/h'a7 tpc ? same output trigger for tpc output groups 0 and 1 address h'ffa5 bit initial value read/write 7 ndr7 0 r/w 6 ndr6 0 r/w 5 ndr5 0 r/w 4 ndr4 0 r/w 3 ndr3 0 r/w 0 ndr0 0 r/w 2 ndr2 0 r/w 1 ndr1 0 r/w next output data for tpc output group 1 next output data for tpc output group 0 address h'ffa7 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? ? different output triggers for tpc output groups 0 and 1 address h'ffa5 bit initial value read/write 7 ndr7 0 r/w 6 ndr6 0 r/w 5 ndr5 0 r/w 4 ndr4 0 r/w 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? next output data for tpc output group 1 address h'ffa7 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ndr3 0 r/w 0 ndr0 0 r/w 2 ndr2 0 r/w 1 ndr1 0 r/w next output data for tpc output group 0
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 628 of 682 rej09b0353-0300 tcsr?timer control/status register h'a8 wdt bit initial value read/write 7 ovf 0 r/(w) 6 wt/ 0 r/w 5 tme 0 r/w 4 ? 1 ? 3 ? 1 ? 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w overflow flag timer mode select it 0 [clearing condition] read ovf when ovf = 1, then write 0 in ovf 1 [setting condition] tcnt changes from h'ff to h'00 0 interval timer: requests interval timer interrupts 1 watchdog timer: generates a reset signal clock select 2 to 0 0 1 /2 /32 /64 /128 /256 /512 /2048 0 1 0 1 0 1 0 1 0 1 0 /4096 1 timer enable 0 1 tcnt is initialized to h'00 and halted tcnt is counting note: * only 0 can be written to clear the flag. * cks2 cks1 cks0 description
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 629 of 682 rej09b0353-0300 tcnt?timer counter h'a9 (read), wdt h'a8 (write) bit initial value read/write 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 0 0 r/w 2 0 r/w 1 0 r/w count value rstcsr?reset control/status register h'ab (read), wdt h'aa (write) bit initial value read/write 7 wrst 0 r/(w) 6 rstoe 0 r/w 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? reset output enable 0 reset signal is not output externally 1 reset signal is output externally watchdog timer reset 0 [clearing condition] reset signal input at res pin, or 0 written by software 1 [setting condition] tcnt overflow generates a reset signal note: * only 0 can be written in bit 7 to clear the flag. *
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 630 of 682 rej09b0353-0300 smr?serial mode register h'b0 sci0 bit initial value read/write 7 c/ 0 r/w 6 chr 0 r/w 5 pe 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w parity enable clock select 1 and 0 cks1 clock source cks0 bit 0 bit 1 0 1 clock /4 clock /16 clock /64 clock 0 0 1 1 a 7 o/ 0 r/w e 0 parity bit is not added or checked 1 parity bit is added and checked parity mode 0 even parity 1 odd parity stop bit length multiprocessor mode 0 multiprocessor function disabled 1 multiprocessor format selected 0 one stop bit 1 two stop bits character length 0 8-bit data 1 7-bit data communication mode 0 asynchronous mode 1 synchronous mode
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 631 of 682 rej09b0353-0300 brr?bit rate register h'b1 sci0 bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w serial communication bit rate setting
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 632 of 682 rej09b0353-0300 scr?serial control register h'b2 sci0 bit initial value read/write 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w transmit interrupt enable 0 transmit-data-empty interrupt request (txi) is disabled 1 transmit-data-empty interrupt request (txi) is enabled receive interrupt enable 0 receive-data-full (rxi) and receive-error (eri) interrupt requests are disabled 1 receive-data-full (rxi) and receive-error (eri) interrupt requests are enabled transmit enable clock enable 1 and 0 cke1 multiprocessor interrupt enable 0 1 clock selection and output asynchronous mode synchronous mode asynchronous mode synchronous mode asynchronous mode synchronous mode asynchronous mode bit 1 cke2 0 1 0 1 bit 2 receive enable synchronous mode 0 multiprocessor interrupts are disabled (normal receive operation) 1 multiprocessor interrupts are enabled 0 receiving is disabled 1 receiving is enabled transmit-end interrupt enable 0 transmitting is disabled 1 transmitting is enabled 0 transmit-end interrupt requests (tei) are disabled 1 transmit-end interrupt requests (tei) are enabled internal clock, sck pin available for generic input/output internal clock, sck pin used for serial clock output internal clock, sck pin used for clock output internal clock, sck pin used for serial clock output external clock, sck pin used for clock input external clock, sck pin used for serial clock input external clock, sck pin used for clock input external clock, sck pin used for serial clock input
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 633 of 682 rej09b0353-0300 tdr?transmit data register h'b3 sci0 bit initial value read/write 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w serial transmit data
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 634 of 682 rej09b0353-0300 ssr?serial status register h'b4 sci0 bit initial value read/write 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 orer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r transmit end 0 [clearing conditions] 1 [setting conditions] reset or transition to standby mode. te is cleared to 0 in scr. tdre is 1 when last bit of serial character is transmitted. ***** multiprocessor bit transfer read tdre when tdre = 1, then write 0 in tdre. multiprocessor bit parity error 0 [clearing conditions] 1 [setting condition] parity error: (parity of receive data does not match parity setting of o/ in smr) reset or transition to standby mode. read per when per = 1, then write 0 in per. e framing error 0 [clearing conditions] 1 [setting condition] framing error (stop bit is 0) reset or transition to standby mode. read fer when fer = 1, then write 0 in fer. overrun error 0 [clearing conditions] 1 [setting condition] overrun error (reception of next serial data ends when rdrf = 1) reset or transition to standby mode. read orer when orer = 1, then write 0 in orer. receive data register full 0 [clearing conditions] 1 [setting condition] serial data is received normally and transferred from rsr to rdr reset or transition to standby mode. read rdrf when rdrf = 1, then write 0 in rdrf. transmit data register empty 0 [clearing conditions] 1 [setting conditions] reset or transition to standby mode. te is 0 in scr data is transferred from tdr to tsr, enabling new data to be written in tdr. read tdre when tdre = 1, then write 0 in tdre. 0 multiprocessor bit value in receive data is 0 1 multiprocessor bit value in receive data is 1 0 multiprocessor bit value in transmit data is 0 1 multiprocessor bit value in transmit data is 1 note: * only 0 can be written to clear the flag.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 635 of 682 rej09b0353-0300 rdr?receive data register h'b5 sci0 bit initial value read/write 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r serial receive data scmr?smart card mode register h'b6 sci0 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 sdir 0 r/w 0 smif 0 r/w 2 sinv 0 r/w 1 ? 1 ? smart card interface mode select 0 smart card interface function is disabled 1 smart card interface function is enabled smart card data invert 0 unmodified tdr contents are transmitted received data is stored unmodified in rdr 1 inverted 1/0 logic levels of tdr contents are transmitted 1/0 logic levels of received data are inverted before storage in rdr smart card data transfer direction 0 tdr contents are transmitted lsb-first received data is stored lsb-first in rdr 1 tdr contents are transmitted msb-first received data is stored msb-first in rdr
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 636 of 682 rej09b0353-0300 smr?serial mode register h'b8 sci1 bit initial value read/write note: bit functions are the same as for sci0. 7 c/ 0 r/w 6 chr 0 r/w 5 pe 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w a 7 o/ 0 r/w e brr?bit rate register h'b9 sci1 bit initial value read/write note: bit functions are the same as for sci0. 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w scr?serial control register h'ba sci1 bit initial value read/write note: bit functions are the same as for sci0. 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w tdr?transmit data register h'bb sci1 bit initial value read/write note: bit functions are the same as for sci0. 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 0 1 r/w 2 1 r/w 1 1 r/w
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 637 of 682 rej09b0353-0300 ssr?serial status register h'bc sci1 bit initial value read/write notes: bit functions are the same as for sci0. * only 0 can be written to clear the flag. 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 orer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpb 0 r * * * * * rdr?receive data register h'bd sci1 bit initial value read/write note: bit functions are the same as for sci0. 7 0 r 6 0 r 5 0 r 4 0 r 3 0 r 0 0 r 2 0 r 1 0 r p1ddr?port 1 data direction register h'c0 port 1 bit modes 1 and 3 initial value read/write initial value read/write modes 5 to 7 7 p1 ddr 1 ? 0 w 7 6 p1 ddr 1 ? 0 w 6 5 p1 ddr 1 ? 0 w 5 4 p1 ddr 1 ? 0 w 4 3 p1 ddr 1 ? 0 w 3 2 p1 ddr 1 ? 0 w 2 1 p1 ddr 1 ? 0 w 1 0 p1 ddr 1 ? 0 w 0 port 1 input/output select 0 generic input pin 1 generic output pin
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 638 of 682 rej09b0353-0300 p2ddr?port 2 data direction register h'c1 port 2 bit modes 1 and 3 initial value read/write initial value read/write modes 5 to 7 7 p2 ddr 1 ? 0 w 7 6 p2 ddr 1 ? 0 w 6 5 p2 ddr 1 ? 0 w 5 4 p2 ddr 1 ? 0 w 4 3 p2 ddr 1 ? 0 w 3 2 p2 ddr 1 ? 0 w 2 1 p2 ddr 1 ? 0 w 1 0 p2 ddr 1 ? 0 w 0 port 2 input/output select 0 generic input pin 1 generic output pin p1dr?port 1 data register h'c2 port 1 bit initial value read/write 7 p1 7 0 r/w 6 p1 6 0 r/w 5 p1 5 0 r/w 4 p1 4 0 r/w 3 p1 3 0 r/w 0 p1 0 0 r/w 2 p1 2 0 r/w 1 p1 1 0 r/w data for port 1 pins p2dr?port 2 data register h'c3 port 2 bit initial value read/write 7 p2 7 0 r/w 6 p2 6 0 r/w 5 p2 5 0 r/w 4 p2 4 0 r/w 3 p2 3 0 r/w 0 p2 0 0 r/w 2 p2 2 0 r/w 1 p2 1 0 r/w data for port 2 pins
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 639 of 682 rej09b0353-0300 p3ddr?port 3 data direction register h'c4 port 3 bit initial value read/write 7 p3 ddr 0 w 7 6 p3 ddr 0 w 6 5 p3 ddr 0 w 5 4 p3 ddr 0 w 4 3 p3 ddr 0 w 3 2 p3 ddr 0 w 2 1 p3 ddr 0 w 1 0 p3 ddr 0 w 0 port 3 input/output select 0 generic input pin 1 generic output pin p3dr?port 3 data register h'c6 port 3 bit initial value read/write 7 p3 0 r/w 7 6 p3 0 r/w 6 5 p3 0 r/w 5 4 p3 0 r/w 4 3 p3 0 r/w 3 2 p3 0 r/w 2 1 p3 0 r/w 1 0 p3 0 r/w 0 data for port 3 pins p5ddr?port 5 data direction register h'c8 port 5 bit modes 1 and 3 initial value read/write initial value read/write modes 5 to 7 7 ? 1 ? 1 ? 6 ? 1 ? 1 ? 5 ? 1 ? 1 ? 4 ? 1 ? 1 ? 3 p5 ddr 1 ? 0 w 3 2 p5 ddr 1 ? 0 w 2 1 p5 ddr 1 ? 0 w 1 0 p5 ddr 1 ? 0 w 0 port 5 input/output select 0 generic input 1 generic output
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 640 of 682 rej09b0353-0300 p6ddr?port 6 data direction register h'c9 port 6 bit initial value read/write 7 ? 1 ? 6 ? 0 w 5 p6 ddr 0 w 5 4 p6 ddr 0 w 4 3 p6 ddr 0 w 3 2 ? 0 w 1 ? 0 w 0 p6 ddr 0 w 0 port 6 input/output select 0 generic input 1 generic output p5dr?port 5 data register h'ca port 5 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 p5 3 0 r/w 2 p5 2 0 r/w 1 p5 1 0 r/w 0 p5 0 0 r/w data for port 5 pins p6dr?port 6 data register h'cb port 6 bit initial value read/write 7 ? 1 ? 6 ? 0 r/w 5 p6 0 r/w 5 4 p6 0 r/w 4 3 p6 0 r/w 3 2 ? 0 r/w 1 ? 0 r/w 0 p6 0 r/w 0 data for port 6 pins
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 641 of 682 rej09b0353-0300 p8ddr?port 8 data direction register h'cd port 8 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 0 w 3 ? 0 w 2 ? 0 w 1 p8 ddr 0 w 1 0 p8 ddr 0 w 0 port 8 input/output select 0 generic input 1 generic output p7dr?port 7 data register h'ce port 7 bit initial value read/write 0 p7 ? r * note: * determined by pins p7 7 to p7 0 . 0 1 p7 ? r * 1 2 p7 ? r * 2 3 p7 ? r * 3 4 p7 ? r * 4 5 p7 ? r * 5 6 p7 ? r * 6 7 p7 ? r * 7 data for port 7 pins p8dr?port 8 data register h'cf port 8 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 p8 0 r/w 1 0 p8 0 r/w 0 data for port 8 pins
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 642 of 682 rej09b0353-0300 p9ddr?port 9 data direction register h'd0 port 9 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 p9 5 ddr 0 w 4 p9 ddr 0 w 4 3 p9 3 ddr 0 w 2 p9 ddr 0 w 2 1 p9 1 ddr 0 w 0 p9 ddr 0 w 0 port 9 input/output select 0 generic input 1 generic output paddr?port a data direction register h'd1 port a bit initial value read/write initial value read/write 7 pa ddr 1 ? 0 w 7 6 pa ddr 0 w 0 w 6 5 pa ddr 0 w 0 w 5 4 pa ddr 0 w 0 w 4 3 pa ddr 0 w 0 w 3 2 pa ddr 0 w 0 w 2 1 pa ddr 0 w 0 w 1 0 pa ddr 0 w 0 w 0 port a input/output select 0 generic input 1 generic output mode 3 modes 1 and 5 to 7 p9dr?port 9 data register h'd2 port 9 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 p9 5 0 r/w 4 p9 4 0 r/w 3 p9 3 0 r/w 2 p9 2 0 r/w 1 p9 1 0 r/w 0 p9 0 0 r/w data for port 9 pins
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 643 of 682 rej09b0353-0300 padr?port a data register h'd3 port a bit initial value read/write 0 pa 0 r/w 0 1 pa 0 r/w 1 2 pa 0 r/w 2 3 pa 0 r/w 3 4 pa 0 r/w 4 5 pa 0 r/w 5 6 pa 0 r/w 6 7 pa 0 r/w 7 data for port a pins pbddr?port b data direction register h'd4 port b bit initial value read/write 7 pb ddr 0 w 7 6 ? 0 w 5 pb ddr 0 w 5 4 pb ddr 0 w 4 3 pb ddr 0 w 3 2 pb ddr 0 w 2 1 pb ddr 0 w 1 0 pb ddr 0 w 0 port b input/output select 0 generic input 1 generic output pbdr?port b data register h'd6 port b bit initial value read/write 0 pb 0 r/w 0 1 pb 0 r/w 1 2 pb 0 r/w 2 3 pb 0 r/w 3 4 pb 0 r/w 4 5 pb 0 r/w 5 6 ? 0 r/w 7 pb 0 r/w 7 data for port b pins
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 644 of 682 rej09b0353-0300 p2pcr?port 2 input pull-up control register h'd8 port 2 bit initial value read/write 7 p2 pcr 0 r/w 7 6 p2 pcr 0 r/w 6 5 p2 pcr 0 r/w 5 4 p2 pcr 0 r/w 4 3 p2 pcr 0 r/w 3 2 p2 pcr 0 r/w 2 1 p2 pcr 0 r/w 1 0 p2 pcr 0 r/w 0 port 2 input pull-up control 7 to 0 0 input pull-up transistor is off 1 input pull-up transistor is on note: valid when the corresponding p2ddr bit is cleared to 0 (designating generic input). p5pcr?port 5 input pull-up control register h'db port 5 bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 p5 pcr 0 r/w 3 2 p5 pcr 0 r/w 2 1 p5 pcr 0 r/w 1 0 p5 pcr 0 r/w 0 port 5 input pull-up control 3 to 0 0 input pull-up transistor is off 1 input pull-up transistor is on note: valid when the corresponding p5ddr bit is cleared to 0 (designating generic input). addra h/l?a/d data register a h/l h'e0, h'e1 a/d bit initial value read/write 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r a/d conversion data 10-bit data giving an a/d conversion result addrah addral
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 645 of 682 rej09b0353-0300 addrb h/l?a/d data register b h/l h'e2, h'e3 a/d bit initial value read/write 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r addrbh addrbl a/d conversion data 10-bit data giving an a/d conversion result addrc h/l?a/d data register c h/l h'e4, h'e5 a/d bit initial value read/write 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r addrch addrcl a/d conversion data 10-bit data giving an a/d conversion result addrd h/l?a/d data register d h/l h'e6, h'e7 a/d bit initial value read/write 14 ad8 0 r 12 ad6 0 r 10 ad4 0 r 8 ad2 0 r 6 ad0 0 r 0 ? 0 r 4 ? 0 r 2 ? 0 r 15 ad9 0 r 13 ad7 0 r 11 ad5 0 r 9 ad3 0 r 7 ad1 0 r 1 ? 0 r 5 ? 0 r 3 ? 0 r addrdh addrdl a/d conversion data 10-bit data giving an a/d conversion result
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 646 of 682 rej09b0353-0300 adcr?a/d control register h'e9 a/d bit initial value read/write 7 trge 0 r/w 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 ? 1 ? 0 ? 1 ? 2 ? 1 ? 1 ? 1 ? trigger enable 0 a/d conversion cannot be externally triggered 1 a/d conversion starts at the fall of the external trigger signal ( ) adtrg
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 647 of 682 rej09b0353-0300 adcsr?a/d control/status register h'e8 a/d bit initial value read/write 7 adf 0 r/(w) 6 adie 0 r/w 5 adst 0 r/w 4 scan 0 r/w 3 cks 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w * note: * only 0 can be written to clear flag. channel select 2 to 0 ch2 1 single mode an an an an an an an ch1 0 1 0 1 channel selection ch0 0 1 0 1 0 1 0 1 0 0 1 2 3 4 5 6 an 7 scan mode an an , an an to an an to an an an , an an to an 0 0 0 0 4 4 4 an to an 4 1 5 2 3 6 7 description group selection a/d end flag a/d interrupt enable a/d start clock select scan mode 0 [clearing condition] read adf while adf = 1, then write 0 in adf 1 [setting conditions] single mode: scan mode: 0 a/d end interrupt request is disabled 1 a/d end interrupt request is enabled 0 a/d conversion is stopped 1 single mode: scan mode: 0 single mode 1 scan mode 0 conversion time = 266 states (maximum) 1 conversion time = 134 states (maximum) a/d conversion ends a/d conversion ends in all selected channels a/d conversion starts; adst is automatically cleared to 0 when conversion ends a/d conversion starts and continues, cycling among the selected channels, until adst is cleared to 0 by software, by a reset, or by a transition to standby mode
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 648 of 682 rej09b0353-0300 astcr?access state control register h'ed bus controller bit initial value read/write 7 ast7 1 r/w 6 ast6 1 r/w 5 ast5 1 r/w 4 ast4 1 r/w 3 ast3 1 r/w 0 ast0 1 r/w 2 ast2 1 r/w 1 ast1 1 r/w area 7 to 0 access state control areas 7 to 0 are two-state access areas areas 7 to 0 are three-state access areas bits 7 to 0 0 1 number of states in access cycle ast7 to ast0 wcr?wait control register h'ee bus controller bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 1 ? 4 ? 1 ? 3 wms1 0 r/w 0 wc0 1 r/w 2 wms0 0 r/w 1 wc1 1 r/w wait count 1 and 0 wc1 number of wait states wc0 bit 0 bit 1 0 1 no wait states inserted by wait-state controller 1 state inserted 2 states inserted 3 states inserted 0 0 1 1 wait mode select 1 and 0 wms1 wait mode wms0 bit 2 bit 3 0 1 programmable wait mode no wait states inserted by wait-state controller pin wait mode 1 pin auto-wait mode 0 0 1 1
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 649 of 682 rej09b0353-0300 wcer?wait controller enable register h'ef bus controller bit initial value read/write 7 wce7 1 r/w 6 wce6 1 r/w 5 wce5 1 r/w 4 wce4 1 r/w 3 wce3 1 r/w 0 wce0 1 r/w 2 wce2 1 r/w 1 wce1 1 r/w wait state controller enable 7 to 0 0 wait-state control is disabled (pin wait mode 0) 1 wait-state control is enabled mdcr?mode control register h'f1 system control bit initial value read/write 7 ? 1 ? 6 ? 1 ? 5 ? 0 ? 4 ? 0 ? 3 ? 0 ? 0 mds0 ? r 2 mds2 ?* r 1 mds1 ? r ** note: * determined by the state of the mode pins (md 2 to md 0 ). mode select 2 to 0 operating mode ? mode 1 ? mode 3 md 1 0 1 bit 1 md 0 0 1 0 1 bit 0 bit 2 md 2 0 ? mode 7 mode 5 0 1 0 1 0 1 1 mode 6
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 650 of 682 rej09b0353-0300 syscr?system control register h'f2 system control bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 ue 1 r/w 0 rame 1 r/w 2 nmieg 0 r/w 1 ? 1 ? software standby 0 sleep instruction causes transition to sleep mode 1 sleep instruction causes transition to software standby mode standby timer select 2 to 0 sts2 0 1 standby timer waiting time = 8192 states waiting time = 16384 states waiting time = 32768 states waiting time = 65536 states waiting time = 131072 states illegal setting bit 6 sts1 0 1 0 1 bit 5 sts0 0 1 0 1 ? bit 4 ram enable 0 on-chip ram is disabled 1 on-chip ram is enabled nmi edge select 0 an interrupt is requested at the falling edge of nmi 1 an interrupt is requested at the rising edge of nmi user bit enable 0 ccr bit 6 (ui) is used as an interrupt mask bit 1 ccr bit 6 (ui) is used as a user bit ?
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 651 of 682 rej09b0353-0300 adrcr?address control register h'f3 bus controller bit initial value read/write initial value read/write modes 1 and 5 to 7 mode 3 7 a 23 e 1 ? 1 r/w 6 a 22 e 1 ? 1 r/w 5 a 21 e 1 ? 1 r/w 4 ? 1 ? 1 ? 3 ? 1 ? 1 ? 0 ? 0 r/w 0 r/w 2 ? 1 ? 1 ? 1 ? 1 ? 1 ? address 23 to 21 enable 0 address output 1 i/o pins other than the above
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 652 of 682 rej09b0353-0300 iscr?irq sense control register h'f4 interrupt controller bit initial value read/write 7 ? 0 r/w 6 ? 0 r/w 5 irq5sc 0 r/w 4 irq4sc 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 irq1sc 0 r/w 0 irq0sc 0 r/w irq 5 , irq 4 , irq 1 and irq 0 sense control 0 interrupts are requested when irq 5 , irq 4 , irq 1 , and irq 0 inputs are low 1 interrupts are requested by falling-edge input at irq 5 , irq 4 , irq 1 and irq 0 ier?irq enable register h'f5 interrupt controller bit initial value read/write 7 ? 0 r/w 6 ? 0 r/w 5 irq5e 0 r/w 4 irq4e 0 r/w 3 ? 0 r/w 2 ? 0 r/w 1 irq1e 0 r/w 0 irq0e 0 r/w irq 5 , irq 4 , irq 1 , irq 0 enable 0 irq 5 , irq 4 , irq 1 and irq 0 interrupts are disabled 1 irq 5 , irq 4 , irq 1 and irq 0 interrupts are enabled
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 653 of 682 rej09b0353-0300 isr?irq status register h'f6 interrupt controller bit initial value read/write 7 ? 0 ? 6 ? 0 ? 5 irq5f 0 r/(w) * 4 irq4f 0 r/(w) * 3 ? 0 ? 2 ? 0 ? 1 irq1f 0 r/(w) * 0 irq0f 0 r/(w) * irq 5 , irq 4 , irq 1 and irq 0 flags bits 5, 4, 1 and 0 0 1 setting and clearing conditions irq5f irq4f irq1f irq0f [clearing conditions]  read irqnf when irqnf = 1, then write 0 in irqnf.  irqnsc = 0, irqn input is high, and interrupt exception handling is carried out.  irqnsc = 1 and irqn interrupt exception handling is carried out. [setting conditions]  irqnsc = 0 and irqn input is low.  irqnsc = 1 and irqn input changes from high to low. note: n = 5, 4, 1 and 0 note: * only 0 can be written to clear the flag.
appendix b internal i/o register field rev.3.00 mar. 26, 2007 page 654 of 682 rej09b0353-0300 ipra?interrupt priority register a h'f8 interrupt controller bit initial value read/write 7 ipra7 0 r/w 6 ipra6 0 r/w 5 ? 0 r/w 4 ipra4 0 r/w 3 ipra3 0 r/w 0 ipra0 0 r/w 2 ipra2 0 r/w 1 ipra1 0 r/w priority level a7, a6, a4 to a0 0 priority level 0 (low priority) 1 priority level 1 (high priority) ? interrupt sources controlled by each bit bit 7 ipra7 bit 6 ipra6 bit 5 ? bit 4 ipra4 bit 3 ipra3 bit 2 ipra2 bit 1 ipra1 bit 0 ipra0 interrupt source irq 0 irq 1 ? irq 4 , irq 5 wdt itu channel 0 itu channel 1 itu channel 2 iprb?interrupt priority register b h'f9 interrupt controller bit initial value read/write 7 iprb7 0 r/w 6 iprb6 0 r/w 5 ? 0 r/w 4 ? 0 r/w 3 iprb3 0 r/w 0 ? 0 r/w 2 iprb2 0 r/w 1 iprb1 0 r/w priority level b7, b6, b3 to b1 0 priority level 0 (low priority) 1 priority level 1 (high priority) ? interrupt sources controlled by each bit bit 7 iprb7 bit 6 iprb6 bit 5 ? bit 4 ? bit 3 iprb3 bit 2 iprb2 bit 1 iprb1 bit 0 ? interrupt source itu channel 3 itu channel 4 ?? sci channel 0 sci channel 1 a/d converter ?
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 655 of 682 rej09b0353-0300 appendix c i/o block diagrams c.1 port 1 block diagram modes 1, 3, and 5 internal data bus (upper) internal address bus p1 n ddr reset r s qd c reset r qd p1 n dr wp1d wp1 c rp1 modes 1, 3, and 5 modes 6 and 7 modes 6 and 7 p1 n * software standby hardware standby wp1d: wp1: rp1: notes: n = 0 to 7 * set priority legend: write to p1ddr write to port 1 read port 1 figure c.1 port 1 block diagram
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 656 of 682 rej09b0353-0300 c.2 port 2 block diagram modes 1, 3, and 5 internal data bus (upper) internal address bus p2 n ddr reset r s qd c reset r qd p2 n dr wp2d wp2 c rp2 modes 1, 3, and 5 modes 6 and 7 modes 6 and 7 p2 n * software standby hardware standby wp2p: rp2p: wp2d: wp2: rp2: notes: n = 0 to 7 * set priority write to p2pcr read p2pcr write to p2ddr write to port 2 read port 2 reset r qd p2 n pcr wp2p c rp2p legend: figure c.2 port 2 block diagram
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 657 of 682 rej09b0353-0300 c.3 port 3 block diagram internal data bus (upper) internal data bus (lower) p3 n ddr reset modes 6 and 7 r qd c reset r qd p3 n dr wp3d wp3 c rp3 modes 1, 3, and 5 modes 6 and 7 p3 n wp3d: wp3: rp3: note: n = 0 to 7 write to p3ddr write to port 3 read port 3 write to external address hardware standby read external address legend: figure c.3 port 3 block diagram
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 658 of 682 rej09b0353-0300 c.4 port 5 block diagram internal data bus (upper) internal address bus p5 n ddr reset r s qd c reset r qd p5 n dr wp5d wp5 c rp5 modes 1, 3, and 5 modes 6 and 7 modes 6 and 7 p5 n * software standby hardware standby wp5p: rp5p: wp5d: wp5: rp5: notes: n = 0 to 3 * set priority write to p5pcr read p5pcr write to p5ddr write to port 5 read port 5 reset r qd p5 n pcr wp5p c rp5p modes 1, 3 legend: figure c.4 port 5 block diagram
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 659 of 682 rej09b0353-0300 c.5 port 6 block diagram p6 0 ddr reset r qd c reset r qd p6 0 dr wp6d wp6 c rp6 p6 0 wp6d: wp6: rp6: write to p6ddr write to port 6 read port 6 internal data bus bus controller wait input enable bus controller wait output modes 6 and 7 legend: figure c.5 (a) port 6 block diagram (pin p6 0 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 660 of 682 rej09b0353-0300 internal data bus p6 n ddr reset r qd c reset r qd p6 n dr wp6d wp6 c rp6 modes 6 and 7 modes 6 and 7 p6 n software standby hardware standby wp6d: wp6: rp6: note: n = 3 to 5 write to p6ddr write to port 6 read port 6 as output rd output wr output modes 1, 3, and 5 legend: figure c.5 (b) port 6 block diagram (pins p6 3 to p6 5 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 661 of 682 rej09b0353-0300 c.6 port 7 block diagram internal data bus p7 n rp7: read port 7 note: n = 0 to 7 a/d converter analog input rp7 input enable legend: figure c.6 port 7 block diagram
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 662 of 682 rej09b0353-0300 c.7 port 8 block diagram internal data bus p8 0 ddr reset r qd c reset r qd p8 0 dr wp8d wp8 c rp8 p8 0 wp8d: wp8: rp8: write to p8ddr write to port 8 read port 8 interrupt controller irq 0 input legend: figure c.7(a) port 8 block diagram (pin p8 0 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 663 of 682 rej09b0353-0300 internal data bus p8 1 ddr reset r qd c reset r qd p8 1 dr wp8d wp8 c rp8 modes 6 and 7 modes 1, 3, and 5 p8 1 wp8d: wp8: rp8: write to p8ddr write to port 8 read port 8 interrupt controller irq 1 input legend: figure c.7 (b) port 8 block diagram (pin p8 1 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 664 of 682 rej09b0353-0300 c.8 port 9 block diagram internal data bus p9 0 ddr reset qd c reset r qd p9 0 dr wp9d wp9 c rp9 p9 0 wp9d: wp9: rp9: write to p9ddr write to port 9 read port 9 sci0 r output enable guard time serial transmit data legend: figure c.8 (a) port 9 block diagram (pin p9 0 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 665 of 682 rej09b0353-0300 internal data bus p9 1 ddr reset qd c reset r qd p9 1 dr wp9d wp9 c rp9 p9 1 wp9d: wp9: rp9: write to p9ddr write to port 9 read port 9 sci1 r output enable serial transmit data legend: figure c.8 (b) port 9 block diagram (pin p9 1 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 666 of 682 rej09b0353-0300 internal data bus p9 n ddr reset qd c reset r qd p9 n dr wp9d wp9 c rp9 p9 n wp9d: wp9: rp9: note: n = 2, 3 write to p9ddr write to port 9 read port 9 sci r input enable serial receive data legend: figure c.8 (c) port 9 block diagram (pin p9 2 , p9 3 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 667 of 682 rej09b0353-0300 internal data bus p9 n ddr reset qd c reset r qd p9 n dr wp9d wp9 c rp9 p9 n wp9d: wp9: rp9: note: n = 4 and 5 write to p9ddr write to port 9 read port 9 sci r clock input enable clock output clock output enable clock input interrupt controller irq 4, irq 5 input legend: figure c.8 (d) port 9 block diagram (pin p9 4 , p9 5 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 668 of 682 rej09b0353-0300 c.9 port a block diagram internal data bus pa n ddr reset qd c reset r qd pa n dr wpad c pa n wpad: wpa: rpa: note: n = 0 or 1 write to paddr write to port a read port a tpc r tpc output enable output trigger next data counter input clock rpa wpa itu legend: figure c.9 (a) port a block diagram (pins pa 0 , pa 1 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 669 of 682 rej09b0353-0300 internal data bus pa n ddr reset qd c reset r qd pa n dr wpad c pa n wpad: wpa: rpa: note: n = 2 or 3 write to paddr write to port a read port a tpc r tpc output enable output trigger next data input capture input rpa wpa itu output enable compare match output counter input clock legend: figure c.9 (b) port a block diagram (pins pa 2 , pa 3 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 670 of 682 rej09b0353-0300 pa n ddr reset software standby address output enable mode 3 q d c reset r qd pa n dr wpad c pa n wpad: wpa: rpa: notes: n = 4 to 7 pa 7 address output enable is fixed at 1 in mode 3. write to paddr write to port a read port a r rpa wpa internal data bus internal address bus tpc tpc output enable output trigger next data itu output enable compare match output input capture input legend: figure c.9 (c) port a block diagram (pins pa 4 to pa 7 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 671 of 682 rej09b0353-0300 c.10 port b block diagram internal data bus pb n ddr reset qd c reset r qd pb n dr wpbd c pb n wpbd: wpb: rpb: note: n = 0 to 3 write to pbddr write to port b read port b tpc r tpc output enable output trigger next data rpb wpb itu compare match output input capture input output enable legend: figure c.10 (a) port b block diagram (pins pb 0 to pb 3 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 672 of 682 rej09b0353-0300 internal data bus pb n ddr reset qd c reset r qd pb n dr wpbd c pb n wpbd: wpb: rpb: note: n = 4 or 5 write to pbddr write to port b read port b tpc r tpc output enable output trigger next data rpb wpb itu output enable compare match output legend: figure c.10 (b) port b block diagram (pins pb 4 , pb 5 )
appendix c i/o block diagrams rev.3.00 mar. 26, 2007 page 673 of 682 rej09b0353-0300 pb 7 ddr reset q d c reset r qd pb 7 dr wpbd c pb 7 wpbd: wpb: rpb: write to pbddr write to port b read port b tpc r tpc output enable output trigger next data rpb wpb internal data bus a/d converter adtrg input legend: figure c.10 (c) port b block diagram (pin pb 7 )
appendix d pin states rev.3.00 mar. 26, 2007 page 674 of 682 rej09b0353-0300 appendix d pin states d.1 port states in each mode table d.1 port states pin name mode reset state hardware standby mode software standby mode program execution state sleep mode ?clock output t h clock output reso * 1 ?t * 2 tt reso p1 7 to p1 0 1, 3 l t t a 7 to a 0 5 t t keep input port (ddr = 0) ta 7 to a 0 (ddr = 1) 6, 7 t t keep i/o port p2 7 to p2 0 1, 3 l t t a 15 to a 8 5 t t keep input port (ddr = 0) ta 15 to a 8 (ddr = 1) 6, 7 t t keep i/o port p3 7 to p3 0 1, 3, 5 t t t d 7 to d 0 6, 7 t t keep i/o port p5 3 to p5 0 1, 3 l t t a 19 to a 16 5 t t keep input port (ddr = 0) ta 19 to a 16 (ddr = 1) 6, 7 t t keep i/o port p6 0 1, 3, 5 t t keep i/o port, wait 6, 7 t t keep i/o port p6 5 to p6 3 1, 3, 5 h t t wr , rd , as 6, 7 t t keep i/o port p7 7 to p7 0 1, 3, 5 to 7 t t t input port p8 0 1, 3, 5 t t keep i/o port 6, 7 t t keep i/o port
appendix d pin states rev.3.00 mar. 26, 2007 page 675 of 682 rej09b0353-0300 pin name mode reset state hardware standby mode software standby mode program execution state sleep mode p8 1 1, 3, 5 t t t [ddr = 0] input port [ddr = 0] h [ddr = 1] h [ddr = 1] 6, 7 t t keep i/o port p9 5 to p9 0 1, 3, 5 to 7 t t keep i/o port pa 3 to pa 0 1, 3, 5 to 7 t t keep i/o port pa 6 to pa 4 3 t t [adrcr = 0] t [adrcr = 1] keep (adrcr = 0) a 21 to a 23 (adrcr = 1) i/o port 1, 5, 6, 7 t t keep i/o port pa 7 3lt t a 20 1, 5, 6, 7 t t keep i/o port pb 7 , pb 5 to pb 0 1, 3, 5 to 7 t t keep i/o port legend: h: high l: low t: high-impedance state keep: input pins are in the high-impedance state; output pins maintain their previous state. ddr: data direction register bit adrcr: address control register notes: 1 mask rom version. dedicated fwe input pin for the f-ztat version. 2 low output only when wdt overflows causes a reset.
appendix d pin states rev.3.00 mar. 26, 2007 page 676 of 682 rej09b0353-0300 d.2 pin states at reset reset in t1 state figure d.1 is a timing diagram for the case in which res goes low during the t1 state of an external memory access cycle. as soon as res goes low, all ports are initialized to the input state. as , rd , and wr go high, and the data bus goes to the high-impedance state. the address bus is initialized to the low output level 0.5 state after the low level of res is sampled. sampling of res takes place at the fall of the system clock ( ). access to external address res h'000000 high impedance high impedance high high high internal reset signal t 1 t 2 t 3 rd (read access) (modes 1, 3, 5) wr (write access) (modes 1, 3, 5) data bus (write access) (modes 1, 3, 5) i/o port (modes 1, 3, 5 to 7) address bus (modes 1, 3, 5) as (modes 1, 3, 5) figure d.1 reset during memory access (reset during t1 state)
appendix d pin states rev.3.00 mar. 26, 2007 page 677 of 682 rej09b0353-0300 reset in t2 state figure d.2 is a timing diagram for the case in which res goes low during the t2 state of an external memory access cycle. as soon as res goes low, all ports are initialized to the input state. as , rd , and wr go high, and the data bus goes to the high-impedance state. the address bus is initialized to the low output level 0.5 state after the low level of res is sampled. the same timing applies when a reset occurs during a wait state (t w ). res h'000000 high impedance high impedance internal reset signal access to external address t 1 t 2 t 3 rd (read access) (modes 1, 3, 5) wr (write access) (modes 1, 3, 5) data bus (write access) (modes 1, 3, 5) i/o port (modes 1, 3, 5 to 7) address bus (modes 1, 3, 5) as (modes 1, 3, 5) figure d.2 reset during memory access (reset during t2 state)
appendix d pin states rev.3.00 mar. 26, 2007 page 678 of 682 rej09b0353-0300 reset in t3 state figure d.3 is a timing diagram for the case in which res goes low during the t 3 state of an external memory access cycle. as soon as res goes low, all ports are initialized to the input state. as , rd , and wr go high, and the data bus goes to the high-impedance state. the address bus outputs are held during the t 3 state.the same timing applies when a reset occurs in the t 2 state of an access cycle to a two-state-access area. res high impedance high impedance internal reset signal access to external address t 1 t 2 t 3 h'000000 rd (read access) (modes 1, 3, 5) wr (write access) (modes 1, 3, 5) data bus (write access) (modes 1, 3, 5) i/o port (modes 1, 3, 5 to 7) address bus (modes 1, 3, 5) as (modes 1, 3, 5) figure d.3 reset during memory access (reset during t3 state)
appendix e timing of transition to and recovery from hardware standby mode rev.3.00 mar. 26, 2007 page 679 of 682 rej09b0353-0300 appendix e timing of transition to and recovery from hardware standby mode timing of transition to hardware standby mode (1) to retain ram contents with the rame bit set to 1 in syscr, drive the res signal low 10 system clock cycles before the stby signal goes low, as shown below. res must remain low until stby goes low (minimum delay from stby low to res high: 0 ns). t 1 10t cyc t 2 0 ns stby res (2) to retain ram contents with the rame bit cleared to 0 in syscr, res does not have to be driven low as in (1). timing of recovery from hardware standby mode drive the res signal low approximately 100 ns before stby goes high. stby res t 100 ns t osc
appendix f product lineup rev.3.00 mar. 26, 2007 page 680 of 682 rej09b0353-0300 appendix f product lineup table f.1 h8/3039 group product lineup product type part number mark code package (package code) h8/3039 hd64f3039f hd64f3039f 80-pin qfp (fp-80a) 5 v version hd64f3039te hd64f3039te 80-pin tqfp (tfp-80c) hd64f3039vf hd64f3039vf 80-pin qfp (fp-80a) flash memory version 3 v version hd64f3039vte hd64f3039vte 80-pin tqfp (tfp-80c) hd6433039f hd6433039( *** )f 80-pin qfp (fp-80a) 5 v version hd6433039te hd6433039( *** )te 80-pin tqfp (tfp-80c) HD6433039VF hd6433039( *** )vf 80-pin qfp (fp-80a) mask rom version 3 v version hd6433039vte hd6433039( *** )vte 80-pin tqfp (tfp-80c) h8/3038 hd6433038f hd6433038( *** )f 80-pin qfp (fp-80a) 5 v version hd6433038te hd6433038( *** )te 80-pin tqfp (tfp-80c) hd6433038vf hd6433038( *** )vf 80-pin qfp (fp-80a) mask rom version 3 v version hd6433038vte hd6433038( *** )vte 80-pin tqfp (tfp-80c) h8/3037 hd6433037f hd6433037( *** )f 80-pin qfp (fp-80a) 5 v version hd6433037te hd6433037( *** )te 80-pin tqfp (tfp-80c) hd6433037vf hd6433037( *** )vf 80-pin qfp (fp-80a) mask rom version 3 v version hd6433037vte hd6433037( *** )vte 80-pin tqfp (tfp-80c) h8/3036 hd6433036f hd6433036( *** )f 80-pin qfp (fp-80a) mask rom version 5 v version hd6433036te hd6433036( *** )te 80-pin tqfp (tfp-80c) hd6433036vf hd6433036( *** )vf 80-pin qfp (fp-80a) 3 v version hd6433036vte hd6433036( *** )vte 80-pin tqfp (tfp-80c) note: ( *** ) in mask rom versions is the rom code.
appendix g package dimensions rev.3.00 mar. 26, 2007 page 681 of 682 rej09b0353-0300 appendix g package dimensions the package dimension that is shown in the renesas semiconductor package data book has priority. note) 1. dimensions" * 1"and" * 2" do not include mold flash 2. dimension" * 3"does not include trim offset. * 1 * 2 * 3 p e d e d 80 1 f 20 21 61 60 41 40 yxm z z e h d h b 2 1 1 detail f c a a l a l terminal cross section p 1 1 c b c b 0.83 0.83 0.10 0.12 0.65 0 8 3.05 0.12 0.17 0.22 0.24 0.32 0.40 0.00 0.30 0.15 0.10 0.25 17.5 17.2 16.9 l 1 z e z d y x c b 1 b p a h d a 2 e d a 1 c 1 e e l h e 1.6 16.9 17.2 17.5 2.70 14 reference symbol dimension in millimeters min nom max 0.5 0.8 1.1 14 p-qfp80-14x14-0.65 1.2g mass[typ.] fp-80a/fp-80av prqp0080jb-a renesas code jeita package code previous code figure g.1 package dimensions (fp-80a)
appendix g package dimensions rev.3.00 mar. 26, 2007 page 682 of 682 rej09b0353-0300 note) 1. dimensions" * 1"and" * 2" do not include mold flash 2. dimension" * 3"does not include trim offset. 12 0.6 0.5 0.4 max nom min dimension in millimeters symbol reference 12 1.00 14.2 14.0 13.8 1.0 h 1 l e e c 1 a 1 e a 2 h d a b p b 1 c x y z d z e l 1 d 13.8 14.0 14.2 1.20 0.00 0.10 0.20 0.17 0.22 0.27 0.20 0.12 0.17 0.22 0.15 0 8 0.5 0.10 0.10 1.25 1.25 index mark * 1 * 2 * 3 y f 80 1 m x 20 21 61 60 41 40 d e d e p b h e h d z z detail f 1 12 c l a a a l 1 1 p terminal cross section b c c b p-tqfp80-12x12-0.50 0.4g mass[typ.] tfp-80c/tfp-80cv ptqp0080kc-a renesas code jeita package code previous code figure g.2 package dimensions (tfp-80c)
renesas 16-bit single-chip microcomputer hardware manual h8/3039 group, h8/3039f-ztat ? publication date: 1st edition, december 1997 rev.3.00, march 26, 2007 published by: sales strategic planning div. renesas technology corp. edited by: customer support department global strategic communication div. renesas solutions corp. ? 2007. renesas technology corp., all rights reserved. printed in japan.
sales strategic planning div. nippon bldg., 2-6-2, ohte-machi, chiyoda-ku, tokyo 100-0004, japan http://www.renesas.com refer to " http://www.renesas.com/en/network " for the latest and detailed information. renesas technology america, inc. 450 holger way, san jose, ca 95134-1368, u.s.a tel: <1> (408) 382-7500, fax: <1> (408) 382-7501 renesas technology europe limited dukes meadow, millboard road, bourne end, buckinghamshire, sl8 5fh, u.k. tel: <44> (1628) 585-100, fax: <44> (1628) 585-900 renesas technology (shanghai) co., ltd. unit 204, 205, aziacenter, no.1233 lujiazui ring rd, pudong district, shanghai, china 200120 tel: <86> (21) 5877-1818, fax: <86> (21) 6887-7898 renesas technology hong kong ltd. 7th floor, north tower, world finance centre, harbour city, 1 canton road, tsimshatsui, kowloon, hong kong tel: <852> 2265-6688, fax: <852> 2730-6071 renesas technology taiwan co., ltd. 10th floor, no.99, fushing north road, taipei, taiwan tel: <886> (2) 2715-2888, fax: <886> (2) 2713-2999 renesas technology singapore pte. ltd. 1 harbour front avenue, #06-10, keppel bay tower, singapore 098632 tel: <65> 6213-0200, fax: <65> 6278-8001 renesas technology korea co., ltd. kukje center bldg. 18th fl., 191, 2-ka, hangang-ro, yongsan-ku, seoul 140-702, korea tel: <82> (2) 796-3115, fax: <82> (2) 796-2145 renesas technology malaysia sdn. bhd unit 906, block b, menara amcorp, amcorp trade centre, no.18, jalan persiaran barat, 46050 petaling jaya, selangor darul ehsan, malaysia tel: <603> 7955-9390, fax: <603> 7955-9510 renesas sales offices colophon 6.0

h8/3039 group, h8/3039f-ztat? rej09b0353-0300 hardware manual 1753, shimonumabe, nakahara-ku, kawasaki-shi, kanagawa 211-8668 japan


▲Up To Search▲   

 
Price & Availability of HD6433039VF

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X